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 00ef5cf commit 2a9d110
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions .github/workflows/branch-restriction.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ 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."
echo "Allowed branches are: ${ALLOWED_BRANCHES[@]}"
echo "SourceBranch name: $SOURCE_BRANCH"
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."
echo "BRANCH_NAME: $BRANCH_NAME"
exit 1
fi

0 comments on commit 2a9d110

Please sign in to comment.