Skip to content

How to make a combined action run on either PR or Push event? #26786

Answered by BrightRan
iamfotx asked this question in Actions
Discussion options

You must be logged in to vote

@iamfotx,

When a commit is pushed from a merged PR, the automatically generated the head commit message generally follows the format “Merge pull request #<pr_number> from /<source_branch>\n\n<pr_title>”.
For example:

You can use the expression “github.event.head_commit.message” to get the head commit message from the github context.
You can use the following if conditional to skip all the jobs in the workflow when the push is from the PR merged.

if: ${{ github.event_name == 'pull_request' || (github.event_name == 'push' && !contains( github.event.head_commit.message, 'Merge pull request')) }}

A simple demo:

on:
  push:
    branches:
      - master
  p…

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
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