-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🧱 Set up commit presence check for the release branches
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
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,33 @@ | ||
name: Check PR Commits Against Main Branch | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- '2*' | ||
pull_request_target: | ||
branches: | ||
- '2*' | ||
|
||
jobs: | ||
check-commits: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout main branch | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: 'main' | ||
|
||
- name: Fetch all history for all tags and branches | ||
run: git fetch --prune --unshallow | ||
|
||
- name: Check if PR commits are in the main branch | ||
run: | | ||
PR_COMMITS=$(git log --format=format:%H origin/${{ github.head_ref }}) | ||
for COMMIT in $PR_COMMITS; do | ||
if ! git merge-base --is-ancestor $COMMIT main; then | ||
echo "::error::Commit $COMMIT is not in the main branch." | ||
echo "Commit $COMMIT from the PR is not present in the main branch." | ||
exit 1 | ||
fi | ||
done | ||
shell: bash |