Skip to content

Commit 2066248

Browse files
authored
use merge SHA when available (#17)
1 parent 40209ac commit 2066248

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

.github/workflows/_shared-docs-build-pr.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ jobs:
159159
160160
core.setOutput('skip-init', skipInit)
161161
162+
// when a PR is first opened, the merge sha is blank
163+
// when a PR is closed, the merge branch doesn't exist
164+
// so let's set a var for the PR ref we'll checkout,
165+
// using the merge SHA usually, but using the merge branch
166+
// if the SHA is blank.
167+
168+
const mergeSha = '${{ github.event.pull_request.merge_commit_sha }}'
169+
if (mergeSha != '') {
170+
core.setOutput('pr-checkout-ref', mergeSha)
171+
} else {
172+
core.setOutput('pr-checkout-ref', 'refs/pull/${{ github.event.number }}/merge')
173+
}
174+
162175
- name: Set up Python
163176
uses: actions/setup-python@v2
164177
with:
@@ -199,7 +212,7 @@ jobs:
199212
#
200213
# since that also works when re-running this action for older commits of
201214
# a PR, **but** then we get https://github.com/ansible-community/github-docs-build/issues/3 back...
202-
ref: refs/pull/${{ github.event.number }}/merge
215+
ref: ${{ steps.vars.outputs.pr-checkout-ref }}
203216
path: ${{ steps.vars.outputs.checkout-path }}
204217

205218
- name: Initialize the build environment (HEAD)

0 commit comments

Comments
 (0)