Limite actions to specific branches in repository settings

I forked a repository from other’s, and start my work on my own branch.

Now I’ have two branch:

master (from the fork source) and feature (my own branch)

Every time I merge updates from the upstream repository into master (like this) and push it to my repository, the master’s .github/workflows/action.yml starts running. However, I don’t want to run the the master. I ONLY want to run actions when I push to my branch  feature

I don’t want to modify the  master  branch. I want to know if there are some way to limite actions to specific branches without modifying original  .github/workflows/*.yml on  master branch. 


1 Like

@kanegreen ,

Currently, we have no a build-in repository setting to choose the which branches can run workflows.
You need to use branches filter ( branches or branches-ignore ) to configure workflows to run on specific branches, or use the if conditional to prevent jobs from running on specific branches.

Considering you need to merge upstream repository into your fork every time, I suggest you use the if conditional to prevent jobs from running when push to the master branch on your forked repository. You need to add the if conditional on every job, and also merge the same configurations into the upstream repository.

if: github.repository != 'forkOrg/forkRepo' || (github.repository == 'forkOrg/forkRepo' && github.ref != 'master')

Relace  forkOrg with your actual organization name, and  forkRepo with your actual repository name.

I don’t have write access in the original repo, I can only write my forked repo.

You mean I need to modify the *.yml on my repo’s master?

@kanegreen ,

Yeah, you need to change to the configurations I mentioned above on the master branch of your forked repository, then open a PR to merge the changes to the  master  branch of the upstream repository, contact the admins or owners of the upstream repository to help you merge this PR.

You only need to modify it once, and just keep the configurations in the future workflow.

is there a subscribe option to be notified when the limitation option appeared ?