From 67d3b16739aa2c081c6a8009b7b303845b15ca5c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 3 Oct 2026 06:04:45 +0000 Subject: [PATCH] Skip license workflow when PR is closed Co-authored-by: parvezmosharafvu <308653838+parvezmosharafvu@users.noreply.github.com> --- .github/workflows/license-check.yml | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/license-check.yml b/.github/workflows/license-check.yml index 80016c4a37..7bd9639476 100644 --- a/.github/workflows/license-check.yml +++ b/.github/workflows/license-check.yml @@ -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 + fi + + exit 1 - 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 -