Repository navigation
Analyzing GitHub Actions logs and implementing fix #20
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 | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,14 +28,30 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| # Check out the actual PR branch so we can push changes back if needed | ||||||||||||||||||||||||||||||||||||||||||
| - name: Check out PR branch | ||||||||||||||||||||||||||||||||||||||||||
| id: pr_branch | ||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||
| GH_TOKEN: ${{ github.token }} | ||||||||||||||||||||||||||||||||||||||||||
| run: gh pr checkout ${{ github.event.pull_request.number }} | ||||||||||||||||||||||||||||||||||||||||||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||
| if gh pr checkout "$PR_NUMBER"; then | ||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| state=$(gh pr view "$PR_NUMBER" --json state --jq '.state') | ||||||||||||||||||||||||||||||||||||||||||
| if [[ "$state" == "CLOSED" ]]; then | ||||||||||||||||||||||||||||||||||||||||||
| echo "skip=true" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||||||||||||||
| echo "::notice::Pull request is closed; skipping license update." | ||||||||||||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+40
to
+44
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. issue (bug_risk): A checkout failure for a merged pull request is treated as an unexpected checkout error because the reported state is Triggers: When the pull request is merged and its branch or pull-request ref can no longer be checked out. Suggested fix: Treat both |
||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+36
to
+47
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. issue (bug_risk): Any checkout failure on a pull request whose API state is Triggers: When a closed pull request encounters a non-closure-related checkout error. Suggested fix: Preserve the checkout failure unless the failure is known to result from a closed or merged pull request, or validate the relevant PR state before checkout and distinguish other errors.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Build UI | ||||||||||||||||||||||||||||||||||||||||||
| if: steps.pr_branch.outputs.skip != 'true' | ||||||||||||||||||||||||||||||||||||||||||
| uses: ./.github/actions/build-ui | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Set up Go | ||||||||||||||||||||||||||||||||||||||||||
| if: steps.pr_branch.outputs.skip != 'true' | ||||||||||||||||||||||||||||||||||||||||||
| uses: actions/setup-go@v7 | ||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||
| go-version-file: "go.mod" | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -44,6 +60,7 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||
| # which causes go-licenses to raise "Package ... does not have module info" errors. | ||||||||||||||||||||||||||||||||||||||||||
| # For more information, https://github.com/google/go-licenses/issues/244#issuecomment-1885098633 | ||||||||||||||||||||||||||||||||||||||||||
| - name: Regenerate licenses | ||||||||||||||||||||||||||||||||||||||||||
| if: steps.pr_branch.outputs.skip != 'true' | ||||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||||
| CI: "true" | ||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -53,11 +70,12 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Check for changes | ||||||||||||||||||||||||||||||||||||||||||
| id: changes | ||||||||||||||||||||||||||||||||||||||||||
| if: steps.pr_branch.outputs.skip != 'true' | ||||||||||||||||||||||||||||||||||||||||||
| continue-on-error: true | ||||||||||||||||||||||||||||||||||||||||||
| run: script/licenses-check | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Commit and push fixes | ||||||||||||||||||||||||||||||||||||||||||
| if: steps.changes.outcome == 'failure' | ||||||||||||||||||||||||||||||||||||||||||
| if: steps.pr_branch.outputs.skip != 'true' && steps.changes.outcome == 'failure' | ||||||||||||||||||||||||||||||||||||||||||
| continue-on-error: true | ||||||||||||||||||||||||||||||||||||||||||
| id: push | ||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -68,7 +86,7 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||
| git push | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Check if already commented | ||||||||||||||||||||||||||||||||||||||||||
| if: steps.changes.outcome == 'failure' && steps.push.outcome == 'failure' | ||||||||||||||||||||||||||||||||||||||||||
| if: steps.pr_branch.outputs.skip != 'true' && steps.changes.outcome == 'failure' && steps.push.outcome == 'failure' | ||||||||||||||||||||||||||||||||||||||||||
| id: check_comment | ||||||||||||||||||||||||||||||||||||||||||
| uses: actions/github-script@v9 | ||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -87,7 +105,7 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||
| core.setOutput('already_commented', alreadyCommented ? 'true' : 'false'); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Comment with instructions if cannot push | ||||||||||||||||||||||||||||||||||||||||||
| if: steps.changes.outcome == 'failure' && steps.push.outcome == 'failure' && steps.check_comment.outputs.already_commented == 'false' | ||||||||||||||||||||||||||||||||||||||||||
| if: steps.pr_branch.outputs.skip != 'true' && steps.changes.outcome == 'failure' && steps.push.outcome == 'failure' && steps.check_comment.outputs.already_commented == 'false' | ||||||||||||||||||||||||||||||||||||||||||
| uses: actions/github-script@v9 | ||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||
| script: | | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -111,6 +129,5 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| - name: Fail check if changes needed | ||||||||||||||||||||||||||||||||||||||||||
| if: steps.changes.outcome == 'failure' | ||||||||||||||||||||||||||||||||||||||||||
| if: steps.pr_branch.outputs.skip != 'true' && steps.changes.outcome == 'failure' | ||||||||||||||||||||||||||||||||||||||||||
| run: exit 1 | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): A closed pull request whose branch is still checkoutable proceeds through license validation and remediation because the workflow checks the pull request state only after
gh pr checkoutfails. The workflow can therefore regenerate and push license updates to a closed pull request.Triggers: When a pull request is closed but its source branch remains available, including a workflow run that continues after the PR is closed.
Suggested fix: Check the pull request state before attempting checkout, or query the state after a successful checkout as well and set
skip=truefor closed pull requests.