chore: add new action to revert direct push into master (#27) #1
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
name: Enforce PR for dev Branch | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
revert-push: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Revert direct push | |
run: | | |
git checkout -b temp-branch | |
git push origin temp-branch | |
git reset --hard HEAD~1 | |
git push origin master --force | |
- name: Create pull request | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{secrets.GITHUB_TOKEN}} | |
commit-message: 'Auto PR: Reverted direct push to master' | |
branch: master | |
title: 'Revert Direct Push and Create PR' | |
body: | | |
A direct push to master was detected and reverted. Please review the changes and merge through this PR. |