From bfc35717744cd2390b0597f790fc27dc866fbfe6 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Tue, 5 Nov 2024 12:39:57 -0800 Subject: [PATCH] ci: Fix workflow events This was found by auditing workflows based on research published here: https://github.com/joeyparrish/workflow-cheat-sheet The research was prompted by a workflow bug in Shaka Streamer --- .github/workflows/build.yaml | 7 +++++-- .github/workflows/release.yaml | 3 +++ .github/workflows/test.yaml | 4 +++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 7319174..3411011 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -25,6 +25,9 @@ on: release_id: required: false type: string + ref: + required: true + type: string secrets: # The GITHUB_TOKEN name is reserved, but not passed through implicitly. # So we call our secret parameter simply TOKEN. @@ -59,7 +62,7 @@ jobs: - uses: actions/checkout@v4 with: path: repo-src - ref: ${{ github.event.pull_request.merge_commit_sha || github.event.push.head }} + ref: ${{ inputs.ref || github.ref }} - name: Configure Build Matrix id: configure @@ -153,7 +156,7 @@ jobs: - uses: actions/checkout@v4 with: path: repo-src - ref: ${{ github.event.pull_request.merge_commit_sha || github.event.push.head }} + ref: ${{ inputs.ref || github.ref }} - name: Install OS packages run: ./repo-src/build-scripts/00-packages.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d769383..6274039 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -42,6 +42,7 @@ jobs: - uses: actions/checkout@v4 with: path: repo-src + ref: ${{ github.ref }} - name: Draft release id: draft_release @@ -63,6 +64,7 @@ jobs: uses: ./.github/workflows/build.yaml with: release_id: ${{ needs.draft_release.outputs.release_id }} + ref: ${{ github.ref }} secrets: TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -74,6 +76,7 @@ jobs: - uses: actions/checkout@v4 with: path: repo-src + ref: ${{ github.ref }} - name: Publish release env: diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c5b5fcd..5e35b9c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -27,7 +27,7 @@ on: # old one. If a PR is updated and a new test run is started, the old test run # will be cancelled automatically to conserve resources. concurrency: - group: ${{ github.workflow }}-${{ github.event.number || github.run_id }} + group: ${{ github.workflow }}-${{ github.event.number }} cancel-in-progress: true # NOTE: Set the repository variable ENABLE_DEBUG to enable debugging via tmate @@ -39,3 +39,5 @@ concurrency: jobs: build: uses: ./.github/workflows/build.yaml + with: + ref: refs/pull/${{ github.event.number }}/merge