-
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.
Added and testing Actions workflow to only accept PR from staging branch
Added and testing Actions workflow to only accept PR from staging branch
- Loading branch information
Showing
2 changed files
with
23 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Enforce Pull Request Source Branch | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
enforce-branch-protection: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check branch source | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
FROM_BRANCH=$(jq -r '.pull_request.base.ref' "$GITHUB_EVENT_PATH") | ||
SOURCE_BRANCH=$(jq -r '.pull_request.head.ref' "$GITHUB_EVENT_PATH") | ||
if [ "$FROM_BRANCH" != "main" ] || [ "$SOURCE_BRANCH" != "staging" ]; then | ||
echo "Pull requests to 'main' must come from 'staging'." | ||
exit 1 | ||
fi |
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