Skip to content

Commit

Permalink
Merge pull request #8 from avixiii-dev/production
Browse files Browse the repository at this point in the history
Production
  • Loading branch information
avixiii-dev authored Dec 25, 2024
2 parents 775870b + b9ea16f commit 3b3dfd8
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/branch-rules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Branch Rules

on:
pull_request:
branches:
- main
- develop
- production

jobs:
check_branch_rules:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Check PR Source and Target
run: |
# Không cho phép PR từ production vào main
if [[ "${{ github.head_ref }}" == "production" && "${{ github.base_ref }}" == "main" ]]; then
echo "❌ Pull requests from production to main are not allowed"
exit 1
fi
# Chỉ cho phép merge vào production từ main
if [[ "${{ github.base_ref }}" == "production" && "${{ github.head_ref }}" != "main" ]]; then
echo "❌ Only main branch can be merged into production"
exit 1
fi
# Feature branches chỉ có thể merge vào develop
if [[ "${{ github.head_ref }}" =~ ^feature/ && "${{ github.base_ref }}" != "develop" ]]; then
echo "❌ Feature branches can only be merged into develop"
exit 1
fi
echo "✅ Branch rules check passed"

0 comments on commit 3b3dfd8

Please sign in to comment.