@@ -175,15 +175,17 @@ jobs:
175
175
176
176
core.setOutput('skip-init', skipInit)
177
177
178
- // when a PR is first opened, the merge sha is blank
179
- // when a PR is closed, the merge branch doesn't exist
180
- // so let's set a var for the PR ref we'll checkout,
181
- // using the merge SHA usually, but using the merge branch
182
- // if the SHA is blank.
178
+ // The merge branch is what we want, but it doesn't exist
179
+ // on closed events. The merge SHA does exist though and
180
+ // should be correct. The merge SHA does not exist when a
181
+ // PR is first opened, and on subsequent updates it is
182
+ // tricky to use; used directly it is probably stale, and
183
+ // would need additional API calls to get the correct value.
184
+ // See also:
185
+ // - https://github.com/ansible-community/github-docs-build/issues/36
183
186
184
- const mergeSha = '${{ github.event.pull_request.merge_commit_sha }}'
185
- if (mergeSha != '') {
186
- core.setOutput('pr-checkout-ref', mergeSha)
187
+ if ('${{ github.event.action }}' == 'closed') {
188
+ core.setOutput('pr-checkout-ref', '${{ github.event.pull_request.merge_commit_sha }}')
187
189
} else {
188
190
core.setOutput('pr-checkout-ref', 'refs/pull/${{ github.event.number }}/merge')
189
191
}
0 commit comments