Checks out the merge commit of a pull request.
This GitHub Action was written for the old HCL syntax, which is no longer supported.
With the new YAML syntax, you can pass the merge_commit_sha
from the pull_request
event payload as ref
parameter to actions/checkout:
name: Test on pull request
on: [pull_request]
jobs:
test_pull_request:
runs-on: ubuntu-latest
steps:
- name: Check out merge commit of pull request
uses: actions/checkout@v1
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
- name: Test
run: npm install && npm test
You can then use jobs.<job_id>.if
to only run your job when it's possible to merge the pull request:
name: Test on pull request
on: [pull_request]
jobs:
test_pull_request:
# Run only on non-merged non-draft mergeable pull requests
if: |
!(
(github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize')
&& !github.event.pull_request.draft
&& !github.event.pull_request.merged
&& github.event.pull_request.merge_commit_sha != null
)
runs-on: ubuntu-latest
steps:
# ...
For a complete example, see this workflow.