Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions .github/workflows/generate-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
github.actor != 'github-actions[bot]' &&
github.actor != 'trueforge-dev-bot[bot]'
permissions:
contents: write
contents: read
Comment thread
bhaveshpatel640 marked this conversation as resolved.

steps:
- name: Create GitHub App token
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
if: steps.decide.outputs.needed == 'true'
run: pnpm sdk:generate

# Forks get a read-only token, so only the commit is skipped. TODO: an approval flow that can push to the fork.
# Same-repo only: App token can push. Forks have no secrets / cannot write the fork head.
- name: Commit generated output
if: steps.decide.outputs.needed == 'true' && steps.app-token.outcome == 'success'
# Passed as env, never interpolated into the script, so it cannot inject shell.
Expand Down Expand Up @@ -141,7 +141,24 @@ jobs:
git commit -m "Regenerate OpenAPI document and TypeScript SDK"
git push origin "HEAD:refs/heads/$BRANCH"

- name: Report skipped commit on fork
# Forks cannot receive the App push (no secrets; App is not installed on the fork).
# Hard-fail if generated output is stale; ask for the changeset in the same message
# (no merge-base/changeset heuristics — those false-positive on unsynced forks).
- name: Fail if generated output is missing on fork
if: steps.decide.outputs.needed == 'true' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
run: |
echo "::notice::Generation succeeded. The commit was skipped because pull requests from forks cannot push; a maintainer will regenerate after merge."
set -euo pipefail

# After CI ran sdk:generate, the tree must match what a same-repo commit would
# have pushed. Dirty → fork head is stale (we cannot push to the fork).
dirty="$(git status --porcelain -- .github/fern/openapi docs/openapi.json packages/sdk pnpm-lock.yaml)"
if [ -n "$dirty" ]; then
echo "::error::OpenAPI/SDK out of date on this fork PR. Run and commit:"
echo " pnpm sdk:generate"
echo " pnpm changeset:sdk-regen # if packages/sdk changed (not only .fern)"
echo "Then push to your fork."
echo "$dirty"
exit 1
fi

echo "::notice::Fork PR generated output matches. If this PR changed packages/sdk (not only .fern), ensure you also committed: pnpm changeset:sdk-regen"
Loading