Skip to content

Commit 7c89daa

Browse files
Phlogistiqueclaude
andcommitted
Use actions/create-github-app-token in CI instead of custom Python script
Dogfood the same approach we recommend to users. Removes the uv dependency from CI. The Python script stays for local dev use via run-e2e-tests.sh. The secret changes from GH_APP_PRIVATE_KEY_PEM_B64 (base64-encoded) to GH_APP_PRIVATE_KEY (raw PEM) — needs a corresponding update in the repo settings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3f716c3 commit 7c89daa

3 files changed

Lines changed: 12 additions & 16 deletions

File tree

.claude/run-e2e-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ acquire_token() {
6363
log_info "Acquiring GitHub App token..."
6464

6565
# Check if required environment variables are set
66-
if [[ -z "$GH_APP_ID" ]] || [[ -z "$GH_APP_PRIVATE_KEY_PEM_B64" ]]; then
67-
log_error "Missing required environment variables: GH_APP_ID and/or GH_APP_PRIVATE_KEY_PEM_B64"
66+
if [[ -z "$GH_APP_ID" ]] || [[ -z "$GH_APP_PRIVATE_KEY" ]]; then
67+
log_error "Missing required environment variables: GH_APP_ID and/or GH_APP_PRIVATE_KEY"
6868
return 1
6969
fi
7070

.github/workflows/tests.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ jobs:
2424
- name: Checkout repository
2525
uses: actions/checkout@v4
2626

27-
- name: Install uv
28-
uses: astral-sh/setup-uv@v4
27+
- name: Generate GitHub App token
28+
id: app-token
29+
uses: actions/create-github-app-token@v2
2930
with:
30-
version: "latest"
31+
app-id: ${{ vars.GH_APP_ID }}
32+
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
3133

3234
- name: Run e2e tests
3335
env:
34-
GH_APP_ID: ${{ vars.GH_APP_ID }}
35-
GH_APP_PRIVATE_KEY_PEM_B64: ${{ secrets.GH_APP_PRIVATE_KEY_PEM_B64 }}
36+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
3637
PRESERVE_ON_FAILURE: "1"
3738
run: |
38-
export GH_TOKEN=$(uv run tests/get_github_app_token.py)
3939
gh auth setup-git
4040
bash tests/test_e2e.sh

tests/get_github_app_token.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
1616
Environment variables required:
1717
- GH_APP_ID: GitHub App ID
18-
- GH_APP_PRIVATE_KEY_PEM_B64: Base64-encoded private key
18+
- GH_APP_PRIVATE_KEY: PEM private key
1919
2020
Usage:
2121
# Run with uv (automatically installs dependencies)
@@ -28,7 +28,6 @@
2828
export GITHUB_TOKEN=$(uv run get_github_app_token.py)
2929
"""
3030

31-
import base64
3231
import json
3332
import os
3433
import sys
@@ -99,15 +98,12 @@ def generate_installation_token():
9998
"""Generate a new installation access token for the GitHub App."""
10099
# Get credentials from environment
101100
app_id = os.getenv("GH_APP_ID")
102-
private_key_b64 = os.getenv("GH_APP_PRIVATE_KEY_PEM_B64")
101+
private_key = os.getenv("GH_APP_PRIVATE_KEY")
103102

104-
if not all([app_id, private_key_b64]):
105-
print("Error: Missing GH_APP_ID or GH_APP_PRIVATE_KEY_PEM_B64", file=sys.stderr)
103+
if not all([app_id, private_key]):
104+
print("Error: Missing GH_APP_ID or GH_APP_PRIVATE_KEY", file=sys.stderr)
106105
sys.exit(1)
107106

108-
# Decode private key
109-
private_key = base64.b64decode(private_key_b64).decode('utf-8')
110-
111107
# Generate JWT
112108
now = int(time.time())
113109
payload = {

0 commit comments

Comments
 (0)