Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

ci: push Generate SDK commits with a GitHub App token (#256)

Bhavesh Patel330d4df8d9e9
diff --git a/.github/workflows/generate-sdk.yaml b/.github/workflows/generate-sdk.yaml
index a8b3fe291..17a3bc465 100644
--- a/.github/workflows/generate-sdk.yaml
+++ b/.github/workflows/generate-sdk.yaml
@@ -31,11 +31,23 @@ jobs:
timeout-minutes: 30
# A pull_request path filter matches the whole PR, not just the new commit,
# so this job's own commits would otherwise retrigger it indefinitely.
- if: github.actor != 'github-actions[bot]'
+ # github-actions[bot]: legacy GITHUB_TOKEN pushes (if any still land).
+ # trueforge-dev-bot[bot]: App-token pushes from this workflow (slug of the Generate SDK App).
+ if: >
+ github.actor != 'github-actions[bot]' &&
+ github.actor != 'trueforge-dev-bot[bot]'
permissions:
contents: write
steps:
+ - name: Create GitHub App token
+ id: app-token
+ if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
+ uses: actions/create-github-app-token@v2
+ with:
+ app-id: ${{ secrets.TRUEFORGE_GENERATE_SDK_APP_ID }}
+ private-key: ${{ secrets.TRUEFORGE_GENERATE_SDK_APP_PRIVATE_KEY }}
+
# Branch tip, not the merge commit, so output can be pushed back; forks need the head repo named.
- name: Check out repository code
uses: actions/checkout@v4
@@ -44,6 +56,7 @@ jobs:
ref: ${{ github.head_ref || github.ref_name }}
# Full history, so the gate below can diff against the base commit.
fetch-depth: 0
+ token: ${{ steps.app-token.outputs.token || github.token }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
@@ -98,10 +111,11 @@ jobs:
# Forks get a read-only token, so only the commit is skipped. TODO: an approval flow that can push to the fork.
- name: Commit generated output
- if: steps.decide.outputs.needed == 'true' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
+ if: steps.decide.outputs.needed == 'true' && steps.app-token.outcome == 'success'
# Passed as env, never interpolated into the script, so it cannot inject shell.
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
+ APP_SLUG: ${{ steps.app-token.outputs.app-slug }}
run: |
set -euo pipefail
@@ -111,8 +125,8 @@ jobs:
exit 0
fi
- git config user.name "github-actions[bot]"
- git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
+ git config user.name "${APP_SLUG}[bot]"
+ git config user.email "${APP_SLUG}[bot]@users.noreply.github.com"
# Bot-authored sdk diffs need a changeset; the PR author never touches this commit.
# Skip packages/sdk/.fern — Fern metadata only, not a consumer-facing change.