Skip to content

Commit 71de548

Browse files
Merge pull request #20 from parvezmosharafvu/copilot/fix-failing-github-actions-job
Analyzing GitHub Actions logs and implementing fix
2 parents c5a7615 + 67d3b16 commit 71de548

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

‎.github/workflows/license-check.yml‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,30 @@ jobs:
2828

2929
# Check out the actual PR branch so we can push changes back if needed
3030
- name: Check out PR branch
31+
id: pr_branch
3132
env:
3233
GH_TOKEN: ${{ github.token }}
33-
run: gh pr checkout ${{ github.event.pull_request.number }}
34+
PR_NUMBER: ${{ github.event.pull_request.number }}
35+
run: |
36+
if gh pr checkout "$PR_NUMBER"; then
37+
exit 0
38+
fi
39+
40+
state=$(gh pr view "$PR_NUMBER" --json state --jq '.state')
41+
if [[ "$state" == "CLOSED" ]]; then
42+
echo "skip=true" >> "$GITHUB_OUTPUT"
43+
echo "::notice::Pull request is closed; skipping license update."
44+
exit 0
45+
fi
46+
47+
exit 1
3448
3549
- name: Build UI
50+
if: steps.pr_branch.outputs.skip != 'true'
3651
uses: ./.github/actions/build-ui
3752

3853
- name: Set up Go
54+
if: steps.pr_branch.outputs.skip != 'true'
3955
uses: actions/setup-go@v7
4056
with:
4157
go-version-file: "go.mod"
@@ -44,6 +60,7 @@ jobs:
4460
# which causes go-licenses to raise "Package ... does not have module info" errors.
4561
# For more information, https://github.com/google/go-licenses/issues/244#issuecomment-1885098633
4662
- name: Regenerate licenses
63+
if: steps.pr_branch.outputs.skip != 'true'
4764
env:
4865
CI: "true"
4966
run: |
@@ -53,11 +70,12 @@ jobs:
5370
5471
- name: Check for changes
5572
id: changes
73+
if: steps.pr_branch.outputs.skip != 'true'
5674
continue-on-error: true
5775
run: script/licenses-check
5876

5977
- name: Commit and push fixes
60-
if: steps.changes.outcome == 'failure'
78+
if: steps.pr_branch.outputs.skip != 'true' && steps.changes.outcome == 'failure'
6179
continue-on-error: true
6280
id: push
6381
run: |
@@ -68,7 +86,7 @@ jobs:
6886
git push
6987
7088
- name: Check if already commented
71-
if: steps.changes.outcome == 'failure' && steps.push.outcome == 'failure'
89+
if: steps.pr_branch.outputs.skip != 'true' && steps.changes.outcome == 'failure' && steps.push.outcome == 'failure'
7290
id: check_comment
7391
uses: actions/github-script@v9
7492
with:
@@ -87,7 +105,7 @@ jobs:
87105
core.setOutput('already_commented', alreadyCommented ? 'true' : 'false');
88106
89107
- name: Comment with instructions if cannot push
90-
if: steps.changes.outcome == 'failure' && steps.push.outcome == 'failure' && steps.check_comment.outputs.already_commented == 'false'
108+
if: steps.pr_branch.outputs.skip != 'true' && steps.changes.outcome == 'failure' && steps.push.outcome == 'failure' && steps.check_comment.outputs.already_commented == 'false'
91109
uses: actions/github-script@v9
92110
with:
93111
script: |
@@ -111,6 +129,5 @@ jobs:
111129
});
112130
113131
- name: Fail check if changes needed
114-
if: steps.changes.outcome == 'failure'
132+
if: steps.pr_branch.outputs.skip != 'true' && steps.changes.outcome == 'failure'
115133
run: exit 1
116-

0 commit comments

Comments
 (0)