Skip to content

Commit 2684f4c

Browse files
committed
Output validation comments even without changes (#4781)
* Output validation comments even without changes Otherwise, a PR that breaks validation but then restores it will keep a comment saying that validation is broken. * Adjust output * Try fixing branch name * Stop trying to display the target branch (cherry picked from commit bbd5dcf)
1 parent 8251ab0 commit 2684f4c

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

.github/validate-pr/index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,18 @@ async function run() {
144144
}
145145
changedApis.sort((a, b) => a.api.localeCompare(b.api))
146146

147+
let comment = `Following you can find the validation changes against the target branch for the API${changedApis.length === 1 ? '' : 's'}.\n\n`
147148
if (changedApis.length > 0) {
148-
let comment = `Following you can find the validation changes for the API${changedApis.length === 1 ? '' : 's'} you have modified.\n\n`
149149
comment += '| API | Status | Request | Response |\n'
150150
comment += '| --- | --- | --- | --- |\n'
151151
for (const change of changedApis) {
152152
comment += buildDiffTableLine(change)
153153
}
154-
comment += `\nYou can validate ${changedApis.length === 1 ? 'this' : 'these'} API${changedApis.length === 1 ? '' : 's'} yourself by using the ${tick}make validate${tick} target.\n`
155-
156-
core.setOutput('has_results', 'true')
157-
core.setOutput('comment_body', comment)
158154
} else {
159-
core.setOutput('has_results', 'false')
155+
comment += '**No changes detected**.\n'
160156
}
157+
comment += `\nYou can validate ${changedApis.length === 1 ? 'this' : 'these'} API${changedApis.length === 1 ? '' : 's'} yourself by using the ${tick}make validate${tick} target.\n`
158+
core.setOutput('comment_body', comment)
161159

162160
core.info('Done!')
163161
}
@@ -231,4 +229,4 @@ function generateResponse (r) {
231229
run().catch((err) => {
232230
core.error(err)
233231
process.exit(1)
234-
})
232+
})

.github/workflows/validate-pr.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ jobs:
7878
body-includes: 'Following you can find the validation changes'
7979

8080
- name: Create or update comment
81-
if: steps.validation.outputs.has_results == 'true'
8281
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
8382
with:
8483
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)