Skip to content

Commit

Permalink
Update prevent-direct-push.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-khattab authored Feb 9, 2024
1 parent 2a22a20 commit ae72bed
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/prevent-direct-push.yml
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

0 comments on commit ae72bed

Please sign in to comment.