Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to limit the jobs to particular branches running on self-hosted runners? #1224

Closed
ghost opened this issue Jul 24, 2021 · 4 comments
Closed
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Jul 24, 2021

Is there a way to add some custom settings on the self-hosted runner instance to reject the jobs triggered from particular branches?

For example, I only want the job to be run on the "main" branch. However someone might create a feature branch, add some dangerous settings to the yaml files in .github/workflows folder to enable the job to run on the feature branch, which is security hole.

Is there way to add some settings in the runner instance to prevent this, or use some other possible solutions to fix the hole? i.e. is it possible to check the branch name on runner instance before running the job and cancel the run if it's not triggered from the valid branches?

Thanks

@fhammerl fhammerl added the enhancement New feature or request label Jul 26, 2021
@fhammerl
Copy link
Contributor

Hi @chengjiaapraamcos, thanks for the feature request. At the moment, there isn't a setting like that, but we're actively investigating similar limitations for runners.

It is recommended to only use self-hosted runners for private repositories. See the docs for more details.

@ghost
Copy link
Author

ghost commented Jul 26, 2021

Hi @fhammerl,

Thanks for your reply.

I am using private repo in our organization but I am looking some strategies to control the permission within the team.

For example, we only allow developers to push code / merge pr into "dev" branch, but there's a concern that they might create a new branch including a customized yml file to consume the "prd" runner and push things to prd environment by using this way, then they might delete the feature branch and make the whole thing hard to track.

Any suggestions to prevent this?

@fhammerl
Copy link
Contributor

@chengjiaapraamcos this one is a lengthy read, but in this issue limiting workflow access is discussed in detail. Here you can find some (unofficial and possibly deprecated) workarounds that are maybe close enough to your use case to be useful.

The team's stance is that this is not a runner feature and should instead be implemented server-side. We don't have a public issue tracker for those services as they are open source.

@ethomson
Copy link
Contributor

Hi! This seems like a possibly useful addition. However, suggestions for GitHub Actions functionality belong in the GitHub feedback forum, where the product managers and engineers will be able to review them. This repository is really only focused on the runner application, which is a very small component of GitHub Actions. If you could open this issue there, that would be very helpful for us! 😄

In the meantime, I'm closing this issue here. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants