Skip to content

Commit 1c43bc2

Browse files
author
rchxx
committed
add back-merge workflow
1 parent f797db0 commit 1c43bc2

File tree

2 files changed

+84
-5
lines changed

2 files changed

+84
-5
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Back Merge handler
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- stable
8+
9+
jobs:
10+
pr_master_to_stable:
11+
runs-on: ubuntu-latest
12+
if: github.ref_name == 'master'
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Check if PR exists
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
run: |
22+
prs=$(gh pr list \
23+
--repo "$GITHUB_REPOSITORY" \
24+
--json baseRefName,headRefName \
25+
--jq '
26+
map(select(.baseRefName == "stable" and .headRefName == "master"))
27+
| length
28+
')
29+
if ((prs > 0)); then
30+
echo "Pull Request already exists"
31+
echo "SKIP=true" >> $GITHUB_ENV
32+
fi
33+
34+
- name: Check if stable is ahead
35+
run: |
36+
commits=$(git rev-list origin/stable..origin/master --count)
37+
if ((commits == 0)); then
38+
echo "No diffs was found between branches"
39+
echo "SKIP=true" >> $GITHUB_ENV
40+
fi
41+
42+
- name: Create Pull Request
43+
if: env.SKIP != 'true'
44+
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'
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
48+
pr_stable_to_develop:
49+
runs-on: ubuntu-latest
50+
if: github.ref_name == 'stable'
51+
steps:
52+
- uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0
55+
56+
- name: Check if PR exists
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
run: |
60+
prs=$(gh pr list \
61+
--repo "$GITHUB_REPOSITORY" \
62+
--json baseRefName,headRefName \
63+
--jq '
64+
map(select(.baseRefName == "develop" and .headRefName == "stable"))
65+
| length
66+
')
67+
if ((prs > 0)); then
68+
echo "Pull Request already exists"
69+
echo "SKIP=true" >> $GITHUB_ENV
70+
fi
71+
72+
- name: Check if stable is ahead
73+
run: |
74+
commits=$(git rev-list origin/develop..origin/stable --count)
75+
if ((commits == 0)); then
76+
echo "No diffs was found between branches"
77+
echo "SKIP=true" >> $GITHUB_ENV
78+
fi
79+
80+
- name: Create Pull Request
81+
if: env.SKIP != 'true'
82+
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'
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/make-prs-for-client-repos.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,34 @@ jobs:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- name: Create PR for Python WebClient Repo
30-
continue-on-error: true
3130
run: gh pr create --base ${{ inputs.target_branch }} --head ${{ inputs.source_branch }} --title '[GitHub Actions] Merge ${{ inputs.source_branch }} -> ${{ inputs.target_branch }}' --label OpenAPI --body 'Autogenerated Pull Request triggered by Github Actions in OpenAPI repository' --repo regulaforensics/DocumentReader-web-python-client
3231
env:
3332
GITHUB_TOKEN: ${{ secrets.REGULA_GITHUB_PUSH_TOKEN }}
3433
java-webclient-pr:
3534
runs-on: ubuntu-latest
3635
steps:
3736
- name: Create PR for Java WebClient Repo
38-
continue-on-error: true
3937
run: gh pr create --base ${{ inputs.target_branch }} --head ${{ inputs.source_branch }} --title '[GitHub Actions] Merge ${{ inputs.source_branch }} -> ${{ inputs.target_branch }}' --label OpenAPI --body 'Autogenerated Pull Request triggered by Github Actions in OpenAPI repository' --repo regulaforensics/DocumentReader-web-java-client
4038
env:
4139
GITHUB_TOKEN: ${{ secrets.REGULA_GITHUB_PUSH_TOKEN }}
4240
js-webclient-pr:
4341
runs-on: ubuntu-latest
4442
steps:
4543
- name: Create PR for JS WebClient Repo
46-
continue-on-error: true
4744
run: gh pr create --base ${{ inputs.target_branch }} --head ${{ inputs.source_branch }} --title '[GitHub Actions] Merge ${{ inputs.source_branch }} -> ${{ inputs.target_branch }}' --label OpenAPI --body 'Autogenerated Pull Request triggered by Github Actions in OpenAPI repository' --repo regulaforensics/DocumentReader-web-js-client
4845
env:
4946
GITHUB_TOKEN: ${{ secrets.REGULA_GITHUB_PUSH_TOKEN }}
5047
csharp-webclient-pr:
5148
runs-on: ubuntu-latest
5249
steps:
5350
- name: Create PR for CSharp WebClient Repo
54-
continue-on-error: true
5551
run: gh pr create --base ${{ inputs.target_branch }} --head ${{ inputs.source_branch }} --title '[GitHub Actions] Merge ${{ inputs.source_branch }} -> ${{ inputs.target_branch }}' --label OpenAPI --body 'Autogenerated Pull Request triggered by Github Actions in OpenAPI repository' --repo regulaforensics/DocumentReader-web-csharp-client
5652
env:
5753
GITHUB_TOKEN: ${{ secrets.REGULA_GITHUB_PUSH_TOKEN }}
5854
openapi-pr:
5955
runs-on: ubuntu-latest
6056
steps:
6157
- name: Create PR for OpenAPI Repo
62-
continue-on-error: true
6358
run: gh pr create --base ${{ inputs.target_branch }} --head ${{ inputs.source_branch }} --title '[GitHub Actions] Merge ${{ inputs.source_branch }} -> ${{ inputs.target_branch }}' --label OpenAPI --body 'Autogenerated Pull Request triggered by Github Actions in OpenAPI repository' --repo regulaforensics/DocumentReader-web-openapi
6459
env:
6560
GITHUB_TOKEN: ${{ secrets.REGULA_GITHUB_PUSH_TOKEN }}

0 commit comments

Comments
 (0)