Skip to content
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
23 changes: 21 additions & 2 deletions .github/workflows/merge_protection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ jobs:
echo "Base branch: ${{ github.base_ref }}"
echo "Head branch: ${{ github.head_ref }}"

# Check main protection
if [[ "${{ github.base_ref }}" == "main" && "${{ github.head_ref }}" != "dev" ]]; then
echo "violation=testnet" >> $GITHUB_OUTPUT
{
echo 'message<<EOF'
echo "❌ **Branch Protection Violation**"
echo ""
echo "You are trying to merge from \`${{ github.head_ref }}\` to \`main\`, but our branch protection rules only allow merges from \`dev\` to \`main\`."
echo ""
echo "**Correct workflow:**"
echo "1. Merge your changes to \`dev\` first"
echo "2. Then create a PR from \`dev\` to \`main\`"
echo ""
echo "This ensures proper code flow and testing procedures."
echo 'EOF'
} >> $GITHUB_OUTPUT
exit 1
fi

# Check testnet protection
if [[ "${{ github.base_ref }}" == "testnet" && "${{ github.head_ref }}" != "main" ]]; then
echo "violation=testnet" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -106,7 +125,7 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ['branch-protection-violation', 'needs-attention']
labels: ['branch-protection-violation']
});

- name: Optional - Auto-close PR
Expand All @@ -125,5 +144,5 @@ jobs:
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: '🔒 This PR has been automatically closed due to branch protection rules. Please follow the correct workflow and create a new PR.'
body: 'This PR has been automatically closed due to branch protection rules. Please follow the correct workflow and create a new PR.'
});