Skip to content

Guard Main Branch

Guard Main Branch #8

Workflow file for this run

---
name: Guard Main Branch
on:
pull_request:
types:
- auto_merge_enabled
branches:
- main
merge_group:
permissions:
contents: read
jobs:
branch-check:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]') }}
steps:
- name: Preamble
run: |
echo "🎉 A $EVENT triggered a ${{ runner.os }} job."
echo "🔎 The branch is $BRANCH in $REPO."
- name: Check out repository code
uses: actions/checkout@v4
- name: Guard the main branch
if: ${{ env.HEAD != 'staging' && env.HEAD != ''}}
run: |
echo "🚫 The main branch is protected."
echo "🚫 Pull requests to main must come from staging branch."
exit 1
- name: Notify
run: |
echo "📣 The job has been completed."
echo "🔔 The main branch is protected."
echo "🍏 This job's status is ${{ job.status }}."