Last active
November 25, 2020 09:00
-
-
Save nurmuhammadsirat/9b31562cafac43ef8b5a0d9bc26b1e34 to your computer and use it in GitHub Desktop.
Allow push to certain branches only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| allowed_branches=(develop branch2 branch3) | |
| is_allowed=0 | |
| for i in ${!allowed_branches[@]}; | |
| do | |
| branch=${allowed_branches[$i]} | |
| if [[ "$branch" = "$(git rev-parse --abbrev-ref HEAD)" ]] | |
| then | |
| is_allowed=1 | |
| fi | |
| done | |
| if [[ "$is_allowed" -ne 1 ]] | |
| then | |
| echo You are only allowed to push to the following branches: ${allowed_branches[@]} | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment