Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 3

Run GitHub action only on specific 'pull_request' actions

I tried this action today, which will clean up branches after they are merged: https://blog.jessfraz.com/post/the-life-of-a-github-action/

 

However, the GitHub action runs on every pull_request action: `opened`, `labeled`, `review_requestes` etc.

 

Since the GitHub action only needs to be run for the `closed` pull_request event, it would be nice to be able to narrow down the `on` command within the workflow.

 

Example of a narrower scope:

workflow "on pull request merge, delete the branch" {
    on = "pull_request.closed"
	
    resolves = ["branch cleanup"]
}

or

workflow "on pull request merge, delete the branch" {
    on = "pull_request"
only = "action=closed" resolves = ["branch cleanup"] }

 

Is this possible somehow, or on your roadmap?

2 Replies
Highlighted
GitHub Staff
Message 2 of 3

Re: Run GitHub action only on specific 'pull_request' actions

Thanks! Ah yes we have had a few requests for this and I will add another :) we are working on the right design for doing this
Pilot Lvl 1
Message 3 of 3

Re: Run GitHub action only on specific 'pull_request' actions

@jessfrazBig +1 for the ability to specify event types to trigger workflows. I have an Action that only needs to fire for pull_request "assigned" and "unassigned" events, but right now it's running on EVERY pull_request event, which is polluting the commit status area with unnecessary check runs.