Skip to content

Commit 1ef003b

Browse files
authored
ci: change automated updates to use PRs (#224)
* ci: change automated updates to use PRs * ci: use environment for auto-update workflow
1 parent 4bd45bd commit 1ef003b

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
* @electron/wg-ecosystem @electron/wg-releases @electron/wg-upgrades
2+
3+
# There is no code owner for abi_registry.json
4+
# so that bots can approve automated PRs to it
5+
abi_registry.json

.github/workflows/update-abi.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
schedule:
66
- cron: '0 15-23,0-3 * * 1-5'
77

8+
permissions: {}
9+
810
jobs:
911
autoupdate:
1012
strategy:
@@ -13,8 +15,9 @@ jobs:
1315
- main
1416
- 3-x-y
1517
runs-on: ubuntu-latest
18+
environment: auto-updater
1619
steps:
17-
- name: Generate GitHub App token
20+
- name: Generate GitHub App token (updater app)
1821
uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
1922
id: generate-token
2023
with:
@@ -42,8 +45,35 @@ jobs:
4245
npm run update-abi-registry
4346
git add abi_registry.json
4447
- name: Commit Changes to ABI registry
48+
id: commit-changes
4549
uses: dsanders11/github-app-commit-action@43de6da2f4d927e997c0784c7a0b61bd19ad6aac # v1.5.0
4650
with:
4751
fail-on-no-changes: false
4852
message: 'feat: update ABI registry'
53+
ref: "feat/update-abi-registry-${{ matrix.branch }}-${{ hashFiles('abi_registry.json') }}"
4954
token: ${{ steps.generate-token.outputs.token }}
55+
- name: Create pull request
56+
if: ${{ steps.commit-changes.outputs.sha }}
57+
shell: bash
58+
env:
59+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
60+
run: |
61+
gh pr create \
62+
--title "feat: update ABI registry (${{ matrix.branch }})" \
63+
--body "Automated PR to update abi_registry.json" \
64+
--head "feat/update-abi-registry-${{ matrix.branch }}-${{ hashFiles('abi_registry.json') }}" \
65+
--base ${{ matrix.branch }}
66+
- name: Generate GitHub App token (approver app)
67+
uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1
68+
if: ${{ steps.commit-changes.outputs.sha }}
69+
id: generate-token-approver
70+
with:
71+
creds: ${{ secrets.APPROVER_GH_APP_CREDS }}
72+
- name: Approve and merge pull request
73+
if: ${{ steps.commit-changes.outputs.sha }}
74+
shell: bash
75+
env:
76+
GITHUB_TOKEN: ${{ steps.generate-token-approver.outputs.token }}
77+
run: |
78+
gh pr review "feat/update-abi-registry-${{ matrix.branch }}-${{ hashFiles('abi_registry.json') }}" --approve
79+
gh pr merge "feat/update-abi-registry-${{ matrix.branch }}-${{ hashFiles('abi_registry.json') }}" --auto --squash

0 commit comments

Comments
 (0)