Skip to content

Commit

Permalink
ci: Fix workflow events (#189)
Browse files Browse the repository at this point in the history
This was found by auditing workflows based on research published here:

https://github.com/joeyparrish/workflow-cheat-sheet

The research was prompted by this repo's PR workflow testing the wrong ref.
  • Loading branch information
joeyparrish authored Nov 6, 2024
1 parent 5a7609b commit 9803243
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ defaults:
# 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 || inputs.ref }}
cancel-in-progress: true

jobs:
Expand All @@ -43,7 +43,7 @@ jobs:
- uses: actions/checkout@v4
with:
path: repo-src
ref: ${{ inputs.ref || github.event.pull_request.merge_commit_sha || github.event.push.head }}
ref: inputs.ref || (github.event.number && format('refs/pull/{0}/merge', github.event.number))

- name: Configure Build Matrix
id: configure
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.event.pull_request.merge_commit_sha || github.event.push.head }}
ref: inputs.ref || (github.event.number && format('refs/pull/{0}/merge', github.event.number))

- name: Set Python version
uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.event.push.head }}
ref: ${{ inputs.ref || github.ref }}

- name: Set Python version
uses: actions/setup-python@v5
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-please.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: refs/tags/${{ needs.release.outputs.tag_name }}
fetch-depth: 0
persist-credentials: false

Expand Down

0 comments on commit 9803243

Please sign in to comment.