diff --git a/.github/workflows/prevent-direct-push.yml b/.github/workflows/prevent-direct-push.yml index 92e6519..11b3e97 100644 --- a/.github/workflows/prevent-direct-push.yml +++ b/.github/workflows/prevent-direct-push.yml @@ -1,4 +1,4 @@ -name: Prevent Direct Pushes to Main +name: Enforce Policy for Main Branch on: push: @@ -6,14 +6,13 @@ on: - 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