Skip to content
Merged
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: 20 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ env:
# Commit timestamp used for deterministic nightly version strings.
# Defined at workflow level so build-binary and publish-nightly always agree.
COMMIT_TIMESTAMP: ${{ github.event.head_commit.timestamp }}
# SENTRY_CLIENT_ID is baked into the binary at build time. Fork PRs can't
# read repo vars (getsentry org policy); fall back to a dummy. The resulting
# binary is only smoke-tested (--help) and never shipped, so any non-empty
# value works; tests tolerate the dummy via test/preload.ts.
SENTRY_CLIENT_ID: ${{ vars.SENTRY_CLIENT_ID || 'ci-fork-pr-dummy' }}

jobs:
changes:
Expand Down Expand Up @@ -112,7 +117,11 @@ jobs:
- uses: actions/checkout@v6
with:
token: ${{ steps.token.outputs.token || github.token }}
ref: ${{ github.head_ref || github.ref_name }}
# Same-repo PRs (token step succeeded): check out the branch head so
# the auto-commit step can push regenerated docs back. Fork PRs leave
# `ref` empty so checkout defaults to GITHUB_REF (the pull_request
# merge SHA, always fetchable from the base repo with github.token).
ref: ${{ steps.token.outcome == 'success' && (github.head_ref || github.ref_name) || '' }}
- uses: oven-sh/setup-bun@v2
- uses: actions/cache@v5
id: cache
Expand Down Expand Up @@ -257,8 +266,9 @@ jobs:
mv package.json.tmp package.json
- name: Build
env:
SENTRY_CLIENT_ID: ${{ vars.SENTRY_CLIENT_ID }}
# Sourcemap upload to Sentry (non-fatal, skipped when token is absent)
# Environment-scoped (production) — must be set at step level to
# resolve correctly; workflow-level env evaluates before the job's
# environment: is applied.
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
# Set on main/release branches so build.ts runs binpunch + creates .gz
RELEASE_BUILD: ${{ github.event_name != 'pull_request' && '1' || '' }}
Expand Down Expand Up @@ -670,7 +680,7 @@ jobs:
run: bun install --frozen-lockfile
- name: Bundle
env:
SENTRY_CLIENT_ID: ${{ vars.SENTRY_CLIENT_ID }}
# Environment-scoped (production) — see note in build-binary.
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: bun run bundle
- name: Smoke test (Node.js)
Expand All @@ -690,6 +700,12 @@ jobs:
# SENTRY_AUTH_TOKEN is scoped to the production environment. Needed by
# the "Inject debug IDs and upload sourcemaps" step below.
environment: ${{ (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')) && 'production' || '' }}
# Hoisted to job level (not step) so the `if: env.SENTRY_AUTH_TOKEN != ''`
Comment thread
BYK marked this conversation as resolved.
# guard on the sourcemap-upload step can see it. Job-level env is resolved
# after `environment:` is applied, so the production-scoped secret resolves
# correctly.
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
steps:
- uses: actions/checkout@v6
- uses: oven-sh/setup-bun@v2
Expand Down Expand Up @@ -727,7 +743,6 @@ jobs:
- name: Inject debug IDs and upload sourcemaps
if: github.event_name == 'push' && env.SENTRY_AUTH_TOKEN != ''
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: sentry
SENTRY_PROJECT: cli-website
run: |
Expand Down
Loading