-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
rchxx
committed
Oct 11, 2024
1 parent
aeeb1b2
commit 7973dc5
Showing
1 changed file
with
84 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,84 @@ | ||
name: Back Merge handler | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- stable | ||
|
||
jobs: | ||
pr_master_to_stable: | ||
runs-on: ubuntu-latest | ||
if: github.ref_name == 'master' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check if PR exists | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
prs=$(gh pr list \ | ||
--repo "$GITHUB_REPOSITORY" \ | ||
--json baseRefName,headRefName \ | ||
--jq ' | ||
map(select(.baseRefName == "stable" and .headRefName == "master")) | ||
| length | ||
') | ||
if ((prs > 0)); then | ||
echo "Pull Request already exists" | ||
echo "SKIP=true" >> $GITHUB_ENV | ||
fi | ||
- name: Check if stable is ahead | ||
run: | | ||
commits=$(git rev-list origin/stable..origin/master --count) | ||
if ((commits == 0)); then | ||
echo "No diffs was found between branches" | ||
echo "SKIP=true" >> $GITHUB_ENV | ||
fi | ||
- name: Create Pull Request | ||
if: env.SKIP != 'true' | ||
run: gh pr create -B stable -H master --title '[GitHub Actions] Merge master -> stable' --label back-merge --body 'Autogenerated Pull Request for `back-merge` triggered by Github Actions' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
pr_stable_to_develop: | ||
runs-on: ubuntu-latest | ||
if: github.ref_name == 'stable' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Check if PR exists | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
prs=$(gh pr list \ | ||
--repo "$GITHUB_REPOSITORY" \ | ||
--json baseRefName,headRefName \ | ||
--jq ' | ||
map(select(.baseRefName == "develop" and .headRefName == "stable")) | ||
| length | ||
') | ||
if ((prs > 0)); then | ||
echo "Pull Request already exists" | ||
echo "SKIP=true" >> $GITHUB_ENV | ||
fi | ||
- name: Check if stable is ahead | ||
run: | | ||
commits=$(git rev-list origin/develop..origin/stable --count) | ||
if ((commits == 0)); then | ||
echo "No diffs was found between branches" | ||
echo "SKIP=true" >> $GITHUB_ENV | ||
fi | ||
- name: Create Pull Request | ||
if: env.SKIP != 'true' | ||
run: gh pr create -B develop -H stable --title '[GitHub Actions] Merge stable -> develop' --label back-merge --body 'Autogenerated Pull Request for `back-merge` triggered by Github Actions' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |