Skip to content

Commit 6fc11d5

Browse files
committed
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 814f583 commit 6fc11d5

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
@@ -83,6 +83,7 @@ jobs:
8383
with:
8484
persist-credentials: false
8585
submodules: true
86+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
8687
- name: Mark the workspace as safe
8788
# https://github.com/actions/checkout/issues/766
8889
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
@@ -104,6 +105,7 @@ jobs:
104105
with:
105106
persist-credentials: false
106107
submodules: true
108+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
107109
- name: Run documentation check
108110
run: |
109111
apt-get -qq update && apt-get -qq -y install curl yq
@@ -120,6 +122,7 @@ jobs:
120122
with:
121123
persist-credentials: false
122124
submodules: true
125+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
123126
- name: Run unacceptable language check
124127
env:
125128
UNACCEPTABLE_WORD_LIST: ${{ inputs.unacceptable_language_check_word_list}}
@@ -136,6 +139,7 @@ jobs:
136139
with:
137140
persist-credentials: false
138141
submodules: true
142+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
139143
- name: Run license header check
140144
env:
141145
PROJECT_NAME: ${{ inputs.license_header_check_project_name }}
@@ -152,6 +156,7 @@ jobs:
152156
with:
153157
persist-credentials: false
154158
submodules: true
159+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
155160
- name: Run broken symlinks check
156161
run: curl -s https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/check-broken-symlinks.sh | bash
157162

@@ -168,6 +173,7 @@ jobs:
168173
with:
169174
persist-credentials: false
170175
submodules: true
176+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
171177
- name: Mark the workspace as safe
172178
# https://github.com/actions/checkout/issues/766
173179
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
@@ -189,6 +195,7 @@ jobs:
189195
with:
190196
persist-credentials: false
191197
submodules: true
198+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
192199
- name: Mark the workspace as safe
193200
# https://github.com/actions/checkout/issues/766
194201
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
@@ -208,6 +215,7 @@ jobs:
208215
with:
209216
persist-credentials: false
210217
submodules: true
218+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
211219
- name: Run yamllint
212220
run: |
213221
which yamllint >/dev/null || ( apt-get update && apt-get install -y yamllint )
@@ -228,6 +236,7 @@ jobs:
228236
with:
229237
persist-credentials: false
230238
submodules: true
239+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
231240
- name: Run flake8
232241
run: |
233242
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
@@ -68,6 +68,8 @@ jobs:
6868
run: swift --version
6969
- name: Checkout repository
7070
uses: actions/checkout@v4
71+
with:
72+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
7173
- name: Set environment variables
7274
if: ${{ inputs.linux_env_vars }}
7375
run: |
@@ -93,6 +95,8 @@ jobs:
9395
steps:
9496
- name: Checkout repository
9597
uses: actions/checkout@v4
98+
with:
99+
ref: ${{ github.ref }} # Include changes to the target branch when action is re-run https://github.com/actions/checkout/issues/1036
96100
- name: Pull Docker image
97101
id: pull_docker_image
98102
run: |

0 commit comments

Comments
 (0)