From 873d7f97340acd04aefb6258c72a02bbc5125038 Mon Sep 17 00:00:00 2001 From: JT2M0L3Y Date: Tue, 14 Jul 2026 22:45:44 -0700 Subject: [PATCH] make badge commit explicit --- .github/workflows/coverage.yml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 8dc826c..cc698b6 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -5,11 +5,15 @@ on: pull_request: branches: - master - types: [opened, synchronize, reopened, closed] + types: [opened, reopened] permissions: contents: write +concurrency: + group: coverage-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: Discord-Node-Coverage: runs-on: ubuntu-latest @@ -18,6 +22,9 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 - name: Set up Node Environment uses: actions/setup-node@v4 @@ -48,9 +55,20 @@ jobs: badge-path: ./imgs/coverage.svg upload-badge: false - - name: Commit badge with merge - if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + - name: Check whether badge commit is already latest + id: badge-check + if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened') + run: | + if [ "$(git log -1 --pretty=%s)" = "update with coverage badge" ]; then + echo "already_latest=true" >> $GITHUB_OUTPUT + else + echo "already_latest=false" >> $GITHUB_OUTPUT + fi + + - name: Commit badge to PR branch + if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened') && steps.badge-check.outputs.already_latest != 'true' uses: stefanzweifel/git-auto-commit-action@v7 with: file_pattern: ./imgs/coverage.svg commit_message: 'update with coverage badge' + branch: ${{ github.head_ref }}