-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a22a20
commit ae72bed
Showing
1 changed file
with
7 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,18 @@ | ||
name: Prevent Direct Pushes to Main | ||
name: Enforce Policy for Main Branch | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
prevent_direct_push: | ||
enforce_policy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check if push is direct to main and not a force push | ||
- name: Check if push is to main and force push | ||
if: > | ||
github.ref == 'refs/heads/main' && | ||
github.event_name == 'push' && | ||
github.event.pull_request == null && | ||
github.event.head_commit != null | ||
github.ref == 'refs/heads/main' && | ||
github.event_name == 'push' && | ||
github.event.pull_request == null && | ||
!contains(github.event.head_commit.message, '[force]') | ||
run: exit 1 # Exit with an error code to fail the workflow |