I want to trigger workflow when the PR is merged only, not closed but merged.
ATM, I’ve been using closed but it caters merge and clos PR both need it only on closed.
I want to trigger workflow when the PR is merged only, not closed but merged.
ATM, I’ve been using closed but it caters merge and clos PR both need it only on closed.
There is only a closed type for Pull request which includes merge. You could add if condition to your job , if: github.event.pull_request.merged == true.
For example:
name: Merge PR
on:
pull_request:
types: [closed]
jobs:
merge-PR:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
Note that the workflow will be triggered when your PR is closed, but the job will only run when it is merged.