Skip to content

Commit b50f1b8

Browse files
authored
chore: create workflows merge from master to develop and check commits (#5611)
* chore: create a workflow from master to develop Signed-off-by: daeyeon ko <[email protected]> * chore: dispatch merge workflow Signed-off-by: daeyeon ko <[email protected]> * chore: add a workflow to check commits that are targets for revert in pr Signed-off-by: daeyeon ko <[email protected]> * chore: workflow name Signed-off-by: daeyeon ko <[email protected]> --------- Signed-off-by: daeyeon ko <[email protected]>
1 parent 056dba4 commit b50f1b8

File tree

3 files changed

+152
-1
lines changed

3 files changed

+152
-1
lines changed

Diff for: .github/workflows/dispatch_master_to_develop.yaml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: "[Dispatch] Master to develop"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'enter version(x.y.z)'
8+
required: true
9+
default: '2.0.0'
10+
11+
env:
12+
VERSION: ${{ github.event.inputs.version }}
13+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
14+
REF_BRANCH: "master"
15+
16+
jobs:
17+
merge_to_develop:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
ref: ${{env.REF_BRANCH}}
24+
fetch-depth: 0
25+
fetch-tags: false
26+
submodules: true
27+
token: ${{ secrets.PAT_TOKEN }}
28+
29+
- name: Fetch develop branch
30+
run: |
31+
git checkout -b develop origin/develop
32+
33+
- name: Configure git
34+
run: |
35+
git log -n 10 --oneline
36+
git branch
37+
git config --global user.email "${{ vars.GIT_EMAIL }}"
38+
git config --global user.name "${{ vars.GIT_USERNAME }}"
39+
40+
- name: Import GPG key
41+
id: import-gpg
42+
uses: crazy-max/[email protected]
43+
with:
44+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
45+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
46+
git_user_signingkey: true
47+
git_commit_gpgsign: true
48+
49+
- name: Merge master into develop
50+
run: |
51+
git merge --no-ff master -m "chore: merge master into develop after ${{ env.VERSION }} version tagging"
52+
53+
- name: Push changes to develop using GitHub push action
54+
uses: ad-m/[email protected]
55+
with:
56+
branch: develop
57+
github_token: ${{ secrets.PAT_TOKEN }}
58+
59+
- name: Notice when job fails
60+
if: failure()
61+
uses: 8398a7/[email protected]
62+
with:
63+
status: ${{job.status}}
64+
fields: repo,workflow,job
65+
author_name: Github Action Slack

Diff for: .github/workflows/dispatch_release.yaml

+36-1
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,29 @@ env:
2020
ARCH: ${{ github.event.inputs.container_arch }}
2121
VERSION: ${{ github.event.inputs.version }}
2222
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
23+
REF_BRANCH: "master"
2324

2425
jobs:
26+
check-branch:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Check branch with regex
30+
run: |
31+
if [[ ! "${{ github.ref }}" =~ ^refs/heads/(${{env.REF_BRANCH}}.*|.*${{env.REF_BRANCH}})$ ]]; then
32+
echo `::error::Branch should always be run from '${{env.REF_BRANCH}}', Running branch: ${github.ref_name}`.
33+
exit 1
34+
fi
35+
- name: Notice when job fails
36+
if: failure()
37+
uses: 8398a7/[email protected]
38+
with:
39+
status: ${{job.status}}
40+
fields: repo,workflow,job
41+
author_name: Github Action Slack
42+
2543
mirinae:
2644
runs-on: ubuntu-latest
45+
needs: check-branch
2746
steps:
2847
- name: Invoke mirinae release workflow
2948
id: mirinae
@@ -63,6 +82,7 @@ jobs:
6382
uses: actions/checkout@v3
6483
with:
6584
submodules: true
85+
ref: ${{ env.REF_BRANCH }}
6686
token: ${{ secrets.PAT_TOKEN }}
6787

6888
- name: Setup Node.js
@@ -91,7 +111,7 @@ jobs:
91111
92112
- name: Import GPG key
93113
id: import-gpg
94-
uses: crazy-max/[email protected]
114+
uses: crazy-max/[email protected]
95115
with:
96116
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
97117
passphrase: ${{ secrets.GPG_PASSPHRASE }}
@@ -129,6 +149,21 @@ jobs:
129149
github_token: ${{ secrets.PAT_TOKEN }}
130150
branch: ${{ github.ref }}
131151

152+
- name: Trigger dispatch_master_to_develop workflow
153+
uses: actions/github-script@v6
154+
with:
155+
github-token: ${{ secrets.PAT_TOKEN }}
156+
script: |
157+
github.rest.actions.createWorkflowDispatch({
158+
owner: "${{ github.repository_owner }}",
159+
repo: "${{ github.event.repository.name }}",
160+
workflow_id: "dispatch_master_to_develop.yaml",
161+
inputs: {
162+
version: "${{ github.event.inputs.version }}",
163+
},
164+
ref: "${{env.REF_BRANCH}}",
165+
});
166+
132167
- name: Set up QEMU
133168
uses: docker/setup-qemu-action@v2
134169

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: [Pull Request] Check Revert Candidate Commits
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
7+
jobs:
8+
check-commits:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Find feat(backend) commits
12+
id: check-commits
13+
env:
14+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15+
run: |
16+
COMMITS=$(gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/commits \
17+
--jq '.[] | select(.commit.message | test("^feat\\(backend")) | .sha + " " + .commit.message')
18+
19+
if [ -z "$COMMITS" ]; then
20+
echo "No matching commits found"
21+
echo "found=false" >> $GITHUB_OUTPUT
22+
else
23+
echo "Found matching commits"
24+
echo "found=true" >> $GITHUB_OUTPUT
25+
COMMITS="${COMMITS//$'\n'/'%0A'}"
26+
echo "commits=$COMMITS" >> $GITHUB_OUTPUT
27+
fi
28+
29+
- name: Comment feat(backend) commits
30+
if: steps.check-commits.outputs.found == 'true'
31+
uses: actions/github-script@v6
32+
with:
33+
script: |
34+
const prNumber = context.payload.pull_request.number;
35+
const commits = `${{ steps.check-commits.outputs.commits }}`.replace(/%0A/g, '\n');
36+
await github.rest.issues.createComment({
37+
...context.repo,
38+
issue_number: prNumber,
39+
body: `⚠️ The following commits require review:\n\n${commits}`
40+
});
41+
42+
- name: Comment no feat(backend) commits
43+
if: steps.check-commits.outputs.found == 'false'
44+
uses: actions/github-script@v6
45+
with:
46+
script: |
47+
await github.rest.issues.createComment({
48+
...context.repo,
49+
issue_number: context.payload.pull_request.number,
50+
body: `✅ There are no commits in this PR that require review.`
51+
});

0 commit comments

Comments
 (0)