Skip to content

How not to trigger a workflow by pushing a merge commit? #26228

Answered by BrightRan
antlu asked this question in Actions
Discussion options

You must be logged in to vote

When a push is from the merge of a PR, after the PR merged, on the target branch, it will automatically generate a head commit with the commit message looks like as " Merge pull request #<PR_ID> from <source_branch>".

You can use the property  github.event.head_commit of github context to access the  head_commit  object. And you also can use the property  github.event.head_commit.message  to view the message of the head commit.

So you can try using the if conditional like as below to skip executing all the jobs in your workflow.

if: (github.event_name == 'push' && contains(toJSON(github.event.head_commit.message), 'Merge pull request ') == false)

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@immjs
Comment options

Answer selected
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants