Skip to content

Commit 003b3ef

Browse files
fix PR workflow checkouts (#38)
* fix PR workflow checkouts * Update .github/workflows/_shared-docs-build-pr.yml Co-authored-by: Felix Fontein <[email protected]> * remove unused constant Co-authored-by: Felix Fontein <[email protected]>
1 parent 843edab commit 003b3ef

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,17 @@ jobs:
175175
176176
core.setOutput('skip-init', skipInit)
177177
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
183186
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 }}')
187189
} else {
188190
core.setOutput('pr-checkout-ref', 'refs/pull/${{ github.event.number }}/merge')
189191
}

0 commit comments

Comments
 (0)