Skip to content

Commit f0ba4e0

Browse files
committed
fix(ci): migrate release automation to GitHub App auth
Switch release-check and back-sync workflows to App token auth. - create installation token in both workflows - keep checkout persist-credentials disabled - use App token for semantic-release and back-sync pushes - set git author to App bot noreply identity
1 parent 897634a commit f0ba4e0

2 files changed

Lines changed: 48 additions & 11 deletions

File tree

.github/workflows/release-check.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,33 @@ jobs:
7272
with:
7373
fetch-depth: 0
7474
ref: ${{ steps.target.outputs.branch }}
75-
ssh-key: ${{ secrets.RELEASE_DEPLOY_KEY }}
7675
persist-credentials: false
7776

78-
- name: Configure git remote for SSH pushes
77+
- name: Create GitHub App token
78+
id: app-token
79+
uses: actions/create-github-app-token@v2
80+
with:
81+
app-id: ${{ secrets.RELEASE_APP_ID }}
82+
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
83+
84+
- name: Resolve GitHub App bot identity
85+
id: app-bot
86+
shell: bash
87+
env:
88+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
89+
run: |
90+
set -euo pipefail
91+
slug='${{ steps.app-token.outputs.app-slug }}'
92+
id="$(gh api "/users/${slug}[bot]" --jq .id)"
93+
echo "name=${slug}[bot]" >> "$GITHUB_OUTPUT"
94+
echo "email=${id}+${slug}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
95+
96+
- name: Configure git identity
7997
shell: bash
8098
run: |
8199
set -euo pipefail
82-
git remote set-url origin git@github.com:${GITHUB_REPOSITORY}.git
83-
git config user.name "github-actions[bot]"
84-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
100+
git config user.name "${{ steps.app-bot.outputs.name }}"
101+
git config user.email "${{ steps.app-bot.outputs.email }}"
85102
86103
- name: Setup Node.js
87104
uses: actions/setup-node@v6
@@ -107,9 +124,9 @@ jobs:
107124

108125
- name: Run semantic-release
109126
env:
110-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
128+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
111129
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
112130
GITHUB_REF: refs/heads/${{ steps.target.outputs.branch }}
113131
GITHUB_REF_NAME: ${{ steps.target.outputs.branch }}
114-
SEMANTIC_RELEASE_REPOSITORY_URL: git@github.com:${{ github.repository }}.git
115132
run: npm run release:run

.github/workflows/sync-main-release-back-to-next.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,34 @@ jobs:
2222
with:
2323
ref: next
2424
fetch-depth: 0
25-
ssh-key: ${{ secrets.RELEASE_DEPLOY_KEY }}
2625
persist-credentials: false
2726

27+
- name: Create GitHub App token
28+
id: app-token
29+
uses: actions/create-github-app-token@v2
30+
with:
31+
app-id: ${{ secrets.RELEASE_APP_ID }}
32+
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
33+
34+
- name: Resolve GitHub App bot identity
35+
id: app-bot
36+
shell: bash
37+
env:
38+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
39+
run: |
40+
set -euo pipefail
41+
slug='${{ steps.app-token.outputs.app-slug }}'
42+
id="$(gh api "/users/${slug}[bot]" --jq .id)"
43+
echo "name=${slug}[bot]" >> "$GITHUB_OUTPUT"
44+
echo "email=${id}+${slug}[bot]@users.noreply.github.com" >> "$GITHUB_OUTPUT"
45+
2846
- name: Configure git
47+
env:
48+
GH_APP_TOKEN: ${{ steps.app-token.outputs.token }}
2949
run: |
30-
git remote set-url origin git@github.com:${GITHUB_REPOSITORY}.git
31-
git config user.name "github-actions[bot]"
32-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
50+
git remote set-url origin "https://x-access-token:${GH_APP_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
51+
git config user.name "${{ steps.app-bot.outputs.name }}"
52+
git config user.email "${{ steps.app-bot.outputs.email }}"
3353
3454
- name: Merge main into next
3555
shell: bash

0 commit comments

Comments
 (0)