-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Improve feedback from CI runs with all secrets #17927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
name: "update-check-action" | ||
description: "Creates or updates a check for a specific PR" | ||
description: "Creates or updates a check for a specific PR and/or a comment" | ||
inputs: | ||
pull_request_number: | ||
description: "Number of the pull request to update checks in" | ||
required: true | ||
check_name: | ||
description: "Name of the check to update" | ||
required: true | ||
required: false | ||
conclusion: | ||
description: "Conclusion to set for the check" | ||
required: true | ||
required: false | ||
github_token: | ||
description: "GitHub token to authenticate with" | ||
default: ${{ github.token }} | ||
|
@@ -25,7 +25,7 @@ runs: | |
steps: | ||
- uses: actions/github-script@v6 | ||
id: update-check-run | ||
if: ${{ always() }} | ||
if: always() && inputs.check_name != '' && inputs.conclusion != '' | ||
env: | ||
number: ${{ inputs.pull_request_number }} | ||
check_name: ${{ inputs.check_name }} | ||
|
@@ -63,7 +63,7 @@ runs: | |
return result; | ||
- uses: actions/github-script@v6 | ||
id: comment | ||
if: ${{ always() }} | ||
if: always() | ||
env: | ||
number: ${{ inputs.pull_request_number }} | ||
run_id: ${{ inputs.run_id }} | ||
|
@@ -83,21 +83,31 @@ runs: | |
exclude_pull_requests: true | ||
}); | ||
|
||
const message = "The CI workflow run with tests that require additional secrets finished as " + process.env.conclusion + ": " + run.html_url | ||
const started = "The CI workflow run with tests that require additional secrets has been started: " + run.html_url | ||
const finished = "The CI workflow run with tests that require additional secrets finished as " + process.env.conclusion + ": " + run.html_url | ||
const comments = await github.paginate(github.rest.issues.listComments.endpoint.merge({ | ||
...context.repo, | ||
issue_number: process.env.number | ||
})) | ||
const exists = comments.filter(comment => comment.body === message).length != 0 | ||
const comment = comments.find(comment => comment.body === started || comment.body === finished) | ||
|
||
if (comment !== undefined) { | ||
if (comment.body === finished) { | ||
return; | ||
} | ||
Comment on lines
+95
to
+97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks unreachable. Even if you comment twice for same SHA two different runs will be started if the automation hasn't posted a comment yet There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This action is called from the test jobs created from a matrix, so there can be more than one. This is done to signal the original PR about the failure as early as possible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one deserves comment IMO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the workflow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, in the body of this |
||
const { data: result } = await github.rest.issues.updateComment({ | ||
...context.repo, | ||
comment.id, | ||
body: finished | ||
}); | ||
|
||
if (exists) { | ||
return; | ||
return result; | ||
} | ||
|
||
const { data: result } = await github.rest.issues.createComment({ | ||
...context.repo, | ||
issue_number: process.env.number, | ||
body: message | ||
body: started | ||
}); | ||
|
||
return result; |
Uh oh!
There was an error while loading. Please reload this page.