Skip to content

Commit

Permalink
Update branch-restriction.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
dugite-git committed Jul 22, 2024
1 parent 745059d commit 9008b47
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/branch-restriction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@ jobs:
steps:
- name: Check branch creation
env:
BRANCH_NAME: ${{ github.ref_name }}
SOURCE_BRANCH: ${{ github.event.before }}
BRANCH_NAME: ${{ github.ref }}
run: |
ALLOWED_BRANCHES=("main" "develop")
for branch in "${ALLOWED_BRANCHES[@]}"; do
if [[ "$SOURCE_BRANCH" == *"$branch" ]]; then
exit 0
fi
done
echo "Branch creation from $SOURCE_BRANCH is not allowed."
exit 1
BRANCH_NAME=${BRANCH_NAME#refs/heads/}
if [[ " ${ALLOWED_BRANCHES[@]} " =~ " ${BRANCH_NAME} " ]]; then
exit 0
else
echo "Branch creation from $BRANCH_NAME is not allowed."
exit 1
fi

0 comments on commit 9008b47

Please sign in to comment.