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

Production #8

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading