Skip to content

Commit f509f58

Browse files
mvgijsselclaude
andauthored
Switch autoversion to a GitHub App identity (#5)
* Switch autoversion to a GitHub App identity The repo's `main` ruleset blocks direct pushes; default GITHUB_TOKEN cannot be granted ruleset bypass. This wires autoversion.yml to: - Mint an installation token from a GitHub App (see README setup) - Check out with that token so `git push` uses the app identity - Commit as <app-slug>[bot] with the verified noreply email format (<user_id>+<slug>[bot]@users.noreply.github.com) Once the app is installed on the repo and added to the ruleset's bypass actors, scheduled and dispatched runs can push directly. Requires repo secrets HERMIT_APP_ID and HERMIT_APP_PRIVATE_KEY. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Scope autoversion job to hermit-autoversion environment Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 70404a9 commit f509f58

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

.github/workflows/autoversion.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,30 @@ name: Auto-version
66
jobs:
77
auto-version:
88
runs-on: ubuntu-latest
9-
permissions:
10-
contents: write
9+
environment: hermit-autoversion
1110
steps:
11+
- name: Generate app token
12+
id: app-token
13+
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
14+
with:
15+
app-id: ${{ secrets.HERMIT_APP_ID }}
16+
private-key: ${{ secrets.HERMIT_APP_PRIVATE_KEY }}
17+
- name: Get app user id
18+
id: app-user
19+
env:
20+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
21+
run: |
22+
echo "id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT"
1223
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
with:
25+
token: ${{ steps.app-token.outputs.token }}
1326
- name: Init Hermit
1427
run: ./bin/hermit env -r >> $GITHUB_ENV
1528
- name: Auto-version
1629
env:
17-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
31+
APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
32+
APP_USER_ID: ${{ steps.app-user.outputs.id }}
1833
run: |
1934
set -xe
2035
hermit -d manifest auto-version --continue-on-error --update-digests $(ls -1 *.hcl | shuf)
@@ -23,7 +38,7 @@ jobs:
2338
echo "No change"
2439
exit 0
2540
fi
26-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
27-
git config --global user.name "github-actions[bot]"
41+
git config --global user.email "${APP_USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com"
42+
git config --global user.name "${APP_SLUG}[bot]"
2843
git commit -am "Auto-versioned: $(git diff --name-only | paste -s -d ' ' -)"
2944
git push

0 commit comments

Comments
 (0)