Skip to content

Commit d703a8a

Browse files
Add App to do the merging (#4461)
1 parent 4a1f877 commit d703a8a

File tree

3 files changed

+45
-27
lines changed

3 files changed

+45
-27
lines changed

.github/workflows/auto-update-app-headers.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
branches:
66
- main
77
paths:
8-
- 'ct/**.sh'
9-
workflow_dispatch:
8+
- "ct/**.sh"
9+
workflow_dispatch:
1010

1111
jobs:
1212
update-app-files:
@@ -25,6 +25,13 @@ jobs:
2525
app-id: ${{ vars.APP_ID }}
2626
private-key: ${{ secrets.APP_PRIVATE_KEY }}
2727

28+
- name: Generate a token for PR approval and merge
29+
id: generate-token-merge
30+
uses: actions/create-github-app-token@v1
31+
with:
32+
app-id: ${{ secrets.APP_ID_APPROVE_AND_MERGE }}
33+
private-key: ${{ secrets.APP_KEY_APPROVE_AND_MERGE }}
34+
2835
# Step 1: Checkout repository
2936
- name: Checkout repository
3037
uses: actions/checkout@v2
@@ -80,7 +87,7 @@ jobs:
8087
--label "automated pr"
8188
env:
8289
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
83-
90+
8491
- name: Approve pull request
8592
if: env.changed == 'true'
8693
env:
@@ -90,13 +97,15 @@ jobs:
9097
if [ -n "$PR_NUMBER" ]; then
9198
gh pr review $PR_NUMBER --approve
9299
fi
93-
100+
94101
- name: Approve pull request and merge
95102
if: env.changed == 'true'
96103
env:
97-
GH_TOKEN: ${{ secrets.PAT_AUTOMERGE }}
104+
GH_TOKEN: ${{ steps.generate-token-merge.outputs.token }}
98105
run: |
99-
PR_NUMBER=$(gh pr list --head "pr-update-app-files" --json number --jq '.[].number')
106+
git config --global user.name "github-actions-automege[bot]"
107+
git config --global user.email "github-actions-automege[bot]@users.noreply.github.com"
108+
PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --json number --jq '.[].number')
100109
if [ -n "$PR_NUMBER" ]; then
101110
gh pr review $PR_NUMBER --approve
102111
gh pr merge $PR_NUMBER --squash --admin

.github/workflows/changelog-pr.yml

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ jobs:
2424
app-id: ${{ vars.APP_ID }}
2525
private-key: ${{ secrets.APP_PRIVATE_KEY }}
2626

27+
- name: Generate a token for PR approval and merge
28+
id: generate-token-merge
29+
uses: actions/create-github-app-token@v1
30+
with:
31+
app-id: ${{ secrets.APP_ID_APPROVE_AND_MERGE }}
32+
private-key: ${{ secrets.APP_KEY_APPROVE_AND_MERGE }}
33+
2734
- name: Checkout code
2835
uses: actions/checkout@v4
2936
with:
@@ -177,7 +184,7 @@ jobs:
177184
}
178185
179186
return await main();
180-
187+
181188
- name: Update CHANGELOG.md
182189
uses: actions/github-script@v7
183190
with:
@@ -202,7 +209,7 @@ jobs:
202209
if (hasMainNotes || hasSubNotes) {
203210
newReleaseNotes += `### ${title}\n\n`;
204211
}
205-
212+
206213
if (hasMainNotes) {
207214
newReleaseNotes += ` ${notes.join("\n")}\n\n`;
208215
}
@@ -267,20 +274,12 @@ jobs:
267274
- name: Approve pull request and merge
268275
if: env.changed == 'true'
269276
env:
270-
GH_TOKEN: ${{ secrets.PAT_AUTOMERGE }}
277+
GH_TOKEN: ${{ steps.generate-token-merge.outputs.token }}
271278
run: |
279+
git config --global user.name "github-actions-automege[bot]"
280+
git config --global user.email "github-actions-automege[bot]@users.noreply.github.com"
272281
PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --json number --jq '.[].number')
273282
if [ -n "$PR_NUMBER" ]; then
274283
gh pr review $PR_NUMBER --approve
275284
gh pr merge $PR_NUMBER --squash --admin
276285
fi
277-
278-
- name: Re-approve pull request after update
279-
if: env.changed == 'true'
280-
env:
281-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
282-
run: |
283-
PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --json number --jq '.[].number')
284-
if [ -n "$PR_NUMBER" ]; then
285-
gh pr review $PR_NUMBER --approve
286-
fi

.github/workflows/update-json-date.yml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ on:
55
branches:
66
- main
77
paths:
8-
- 'frontend/public/json/**.json'
9-
workflow_dispatch:
8+
- "frontend/public/json/**.json"
9+
workflow_dispatch:
1010

1111
jobs:
1212
update-app-files:
@@ -25,10 +25,17 @@ jobs:
2525
app-id: ${{ vars.APP_ID }}
2626
private-key: ${{ secrets.APP_PRIVATE_KEY }}
2727

28+
- name: Generate a token for PR approval and merge
29+
id: generate-token-merge
30+
uses: actions/create-github-app-token@v1
31+
with:
32+
app-id: ${{ secrets.APP_ID_APPROVE_AND_MERGE }}
33+
private-key: ${{ secrets.APP_KEY_APPROVE_AND_MERGE }}
34+
2835
- name: Generate dynamic branch name
2936
id: timestamp
3037
run: echo "BRANCH_NAME=pr-update-json-$(date +'%Y%m%d%H%M%S')" >> $GITHUB_ENV
31-
38+
3239
- name: Set up GH_TOKEN
3340
env:
3441
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -38,7 +45,7 @@ jobs:
3845
- name: Checkout Repository
3946
uses: actions/checkout@v4
4047
with:
41-
fetch-depth: 2 # Ensure we have the last two commits
48+
fetch-depth: 2 # Ensure we have the last two commits
4249

4350
- name: Get Previous Commit
4451
id: prev_commit
@@ -103,8 +110,8 @@ jobs:
103110
- name: Commit and create PR if changes exist
104111
if: env.changed == 'true'
105112
run: |
106-
107-
113+
114+
108115
git commit -m "Update date in json"
109116
git checkout -b ${{ env.BRANCH_NAME }}
110117
git push origin ${{ env.BRANCH_NAME }}
@@ -126,12 +133,15 @@ jobs:
126133
if [ -n "$PR_NUMBER" ]; then
127134
gh pr review $PR_NUMBER --approve
128135
fi
136+
129137
- name: Approve pull request and merge
130138
if: env.changed == 'true'
131139
env:
132-
GH_TOKEN: ${{ secrets.PAT_AUTOMERGE }}
140+
GH_TOKEN: ${{ steps.generate-token-merge.outputs.token }}
133141
run: |
134-
PR_NUMBER=$(gh pr list --head "${{ env.BRANCH_NAME }}" --json number --jq '.[].number')
142+
git config --global user.name "github-actions-automege[bot]"
143+
git config --global user.email "github-actions-automege[bot]@users.noreply.github.com"
144+
PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --json number --jq '.[].number')
135145
if [ -n "$PR_NUMBER" ]; then
136146
gh pr review $PR_NUMBER --approve
137147
gh pr merge $PR_NUMBER --squash --admin

0 commit comments

Comments
 (0)