Skip to content

Commit bc60da5

Browse files
authored
Merge pull request #5 from Daemon-Computer/dev
Added main branch protection
2 parents ce85517 + 0092df4 commit bc60da5

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

.github/workflows/merge_protection.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,25 @@ jobs:
1919
echo "Base branch: ${{ github.base_ref }}"
2020
echo "Head branch: ${{ github.head_ref }}"
2121
22+
# Check main protection
23+
if [[ "${{ github.base_ref }}" == "main" && "${{ github.head_ref }}" != "dev" ]]; then
24+
echo "violation=testnet" >> $GITHUB_OUTPUT
25+
{
26+
echo 'message<<EOF'
27+
echo "❌ **Branch Protection Violation**"
28+
echo ""
29+
echo "You are trying to merge from \`${{ github.head_ref }}\` to \`main\`, but our branch protection rules only allow merges from \`dev\` to \`main\`."
30+
echo ""
31+
echo "**Correct workflow:**"
32+
echo "1. Merge your changes to \`dev\` first"
33+
echo "2. Then create a PR from \`dev\` to \`main\`"
34+
echo ""
35+
echo "This ensures proper code flow and testing procedures."
36+
echo 'EOF'
37+
} >> $GITHUB_OUTPUT
38+
exit 1
39+
fi
40+
2241
# Check testnet protection
2342
if [[ "${{ github.base_ref }}" == "testnet" && "${{ github.head_ref }}" != "main" ]]; then
2443
echo "violation=testnet" >> $GITHUB_OUTPUT
@@ -106,7 +125,7 @@ jobs:
106125
owner: context.repo.owner,
107126
repo: context.repo.repo,
108127
issue_number: context.issue.number,
109-
labels: ['branch-protection-violation', 'needs-attention']
128+
labels: ['branch-protection-violation']
110129
});
111130
112131
- name: Optional - Auto-close PR
@@ -125,5 +144,5 @@ jobs:
125144
owner: context.repo.owner,
126145
repo: context.repo.repo,
127146
issue_number: context.issue.number,
128-
body: '🔒 This PR has been automatically closed due to branch protection rules. Please follow the correct workflow and create a new PR.'
147+
body: 'This PR has been automatically closed due to branch protection rules. Please follow the correct workflow and create a new PR.'
129148
});

0 commit comments

Comments
 (0)