Skip to content

Commit

Permalink
feature(devops-work): add github action to Prevent Direct Pushes to Main
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-khattab committed Feb 9, 2024
1 parent a01f5ed commit 31dfcc9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/prevent-direct-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Prevent Direct Pushes to Main

on:
push:
branches:
- main

jobs:
prevent_direct_push:
runs-on: ubuntu-latest

steps:
- name: Check if push is direct to main and not a force push
if: >
github.ref == 'refs/heads/main' &&
github.event_name == 'push' &&
github.event.pull_request == null &&
github.event.head_commit != null
run: exit 1 # Exit with an error code to fail the workflow

0 comments on commit 31dfcc9

Please sign in to comment.