Skip to content

Commit b3aa618

Browse files
ahoppensimonjbeaumont
authored andcommitted
Include changes to the target branch when action is re-run
When a GitHub action is re-run, it uses the same context as the original run. This means that it runs on the exact same merge commit and does not pick up changes done to the base branch since the last run. In case the base branch is was failing when a PR was opened, this means that we can’t get CI to pass by fixing the base branch without pushing a new commit to the PR branch. Adding `ref: ${{ github.ref }}` to the `actions/checkout` action works around this by checking out the PR merge ref (ie. `refs/pull/<pr_number>/merge`) instead of a fixed commit and the PR merge ref is updated, as described in actions/checkout#1036.
1 parent e3c6d03 commit b3aa618

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

.github/workflows/soundness.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
with:
8585
persist-credentials: false
8686
submodules: true
87+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
8788
- name: Mark the workspace as safe
8889
# https://github.com/actions/checkout/issues/766
8990
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
@@ -106,6 +107,7 @@ jobs:
106107
with:
107108
persist-credentials: false
108109
submodules: true
110+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
109111
- name: Run documentation check
110112
run: |
111113
apt-get -qq update && apt-get -qq -y install curl yq
@@ -123,6 +125,7 @@ jobs:
123125
with:
124126
persist-credentials: false
125127
submodules: true
128+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
126129
- name: Run unacceptable language check
127130
env:
128131
UNACCEPTABLE_WORD_LIST: ${{ inputs.unacceptable_language_check_word_list}}
@@ -140,6 +143,7 @@ jobs:
140143
with:
141144
persist-credentials: false
142145
submodules: true
146+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
143147
- name: Run license header check
144148
env:
145149
PROJECT_NAME: ${{ inputs.license_header_check_project_name }}
@@ -157,6 +161,7 @@ jobs:
157161
with:
158162
persist-credentials: false
159163
submodules: true
164+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
160165
- name: Run broken symlinks check
161166
run: curl -s https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/check-broken-symlinks.sh | bash
162167

@@ -174,6 +179,7 @@ jobs:
174179
with:
175180
persist-credentials: false
176181
submodules: true
182+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
177183
- name: Mark the workspace as safe
178184
# https://github.com/actions/checkout/issues/766
179185
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
@@ -196,6 +202,7 @@ jobs:
196202
with:
197203
persist-credentials: false
198204
submodules: true
205+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
199206
- name: Mark the workspace as safe
200207
# https://github.com/actions/checkout/issues/766
201208
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
@@ -216,6 +223,7 @@ jobs:
216223
with:
217224
persist-credentials: false
218225
submodules: true
226+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
219227
- name: Run yamllint
220228
run: |
221229
which yamllint >/dev/null || ( apt-get update && apt-get install -y yamllint )
@@ -237,6 +245,7 @@ jobs:
237245
with:
238246
persist-credentials: false
239247
submodules: true
248+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
240249
- name: Run flake8
241250
run: |
242251
pip3 install flake8 flake8-import-order

.github/workflows/swift_package_test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ jobs:
6969
- name: Checkout repository
7070
if: env.ACT != 'true'
7171
uses: actions/checkout@v4
72+
with:
73+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
7274
- name: Set environment variables
7375
if: ${{ inputs.linux_env_vars }}
7476
run: |
@@ -95,6 +97,8 @@ jobs:
9597
- name: Checkout repository
9698
if: env.ACT != 'true'
9799
uses: actions/checkout@v4
100+
with:
101+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
98102
- name: Pull Docker image
99103
id: pull_docker_image
100104
run: |

0 commit comments

Comments
 (0)