Skip to content

Commit

Permalink
Merge pull request #75 from puppetlabs/maint-update_checkout_ref_mend
Browse files Browse the repository at this point in the history
(maint) - Update checkout ref on mend pr trigger
  • Loading branch information
LukasAud authored Feb 1, 2024
2 parents d79af84 + bec3620 commit bc2b3bd
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion .github/workflows/tooling_mend_ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,30 @@ on:
jobs:

mend:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: "ubuntu-latest"

steps:
# To access the mend secrets, we now need to trigger on pull_request_target event
# which by default runs in the context of the main branch, so we use this to retrieve
# the PR object and then checkout the merge commit sha
- name: "Retrieve PR"
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
id: pr
with:
script: |
const { data: pullRequest } = await github.rest.pulls.get({
...context.repo,
pull_number: context.payload.pull_request.number,
});
return pullRequest
- name: "checkout"
uses: "actions/checkout@v4"
with:
fetch-depth: 1
# If we are on a PR, checkout the merge commit sha, else checkout the main branch
ref: ${{ fromJSON(steps.pr.outputs.result).merge_commit_sha || 'refs/heads/main'}}

- name: "setup ruby"
uses: "ruby/setup-ruby@v1"
Expand Down

0 comments on commit bc2b3bd

Please sign in to comment.