|
36 | 36 | runs-on: blacksmith-8vcpu-ubuntu-2404 |
37 | 37 | permissions: |
38 | 38 | contents: read |
| 39 | + # Pylon Connect's public config lives in this environment, the same source |
| 40 | + # `relay_public_config` in release.yml feeds to desktop, CLI, and hosted web. |
| 41 | + # Mobile reads it from here too, so the four surfaces cannot drift apart. |
| 42 | + environment: production |
39 | 43 | env: |
40 | 44 | APP_VARIANT: production |
41 | 45 | NODE_OPTIONS: --max-old-space-size=8192 |
| 46 | + CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }} |
| 47 | + CLERK_JWT_TEMPLATE: ${{ vars.CLERK_JWT_TEMPLATE }} |
| 48 | + CLERK_CLI_OAUTH_CLIENT_ID: ${{ vars.CLERK_CLI_OAUTH_CLIENT_ID }} |
| 49 | + RELAY_DOMAIN: ${{ vars.RELAY_DOMAIN }} |
| 50 | + RELAY_API_ZONE_NAME: ${{ vars.RELAY_API_ZONE_NAME }} |
| 51 | + # app.config.ts reads these to build `extra.eas.projectId`, and eas-cli |
| 52 | + # resolves the project from it. They otherwise live only in a gitignored |
| 53 | + # .env.local, so without them here every eas command fails with "EAS |
| 54 | + # project not configured". |
| 55 | + PYLON_EAS_PROJECT_ID: ${{ vars.PYLON_EAS_PROJECT_ID }} |
| 56 | + PYLON_EAS_OWNER: ${{ vars.PYLON_EAS_OWNER }} |
42 | 57 | steps: |
43 | 58 | - id: expo-token |
44 | 59 | name: Check for EXPO_TOKEN |
@@ -91,13 +106,60 @@ jobs: |
91 | 106 | # ignored build script (no allowBuilds config outside the repo). |
92 | 107 | packager: npm |
93 | 108 |
|
| 109 | + # EAS build servers read their own environment store, not this checkout — |
| 110 | + # a repo-root .env is gitignored and never reaches them. So the GitHub |
| 111 | + # values are mirrored into EAS here, keeping one source of truth instead |
| 112 | + # of a hand-maintained expo.dev copy that silently drifts. |
| 113 | + - name: Sync Connect config to the EAS environment |
| 114 | + if: steps.expo-token.outputs.present == 'true' |
| 115 | + working-directory: apps/mobile |
| 116 | + env: |
| 117 | + EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} |
| 118 | + run: | |
| 119 | + set -euo pipefail |
| 120 | +
|
| 121 | + relay_domain="${RELAY_DOMAIN:-}" |
| 122 | + if [[ -z "$relay_domain" && -n "${RELAY_API_ZONE_NAME:-}" ]]; then |
| 123 | + relay_domain="relay.$RELAY_API_ZONE_NAME" |
| 124 | + fi |
| 125 | + # Partial configuration is treated as none, matching `relay_public_config` |
| 126 | + # in release.yml: half-configured Connect fails at runtime in the user's |
| 127 | + # app rather than here, where the cause is still visible. |
| 128 | + missing=() |
| 129 | + for name in relay_domain CLERK_PUBLISHABLE_KEY CLERK_JWT_TEMPLATE CLERK_CLI_OAUTH_CLIENT_ID; do |
| 130 | + if [[ -z "${!name:-}" ]]; then |
| 131 | + missing+=("$name") |
| 132 | + fi |
| 133 | + done |
| 134 | + if (( ${#missing[@]} > 0 )); then |
| 135 | + printf 'Connect is not configured (missing: %s); leaving the EAS environment untouched.\n' "${missing[*]}" >&2 |
| 136 | + exit 0 |
| 137 | + fi |
| 138 | +
|
| 139 | + sync() { |
| 140 | + echo "Syncing $1 to the EAS production, preview, and development environments." |
| 141 | + eas env:create \ |
| 142 | + --name "$1" --value "$2" \ |
| 143 | + --environment production --environment preview --environment development \ |
| 144 | + --visibility plaintext --type string --scope project \ |
| 145 | + --force --non-interactive |
| 146 | + } |
| 147 | + sync T3CODE_CLERK_PUBLISHABLE_KEY "$CLERK_PUBLISHABLE_KEY" |
| 148 | + sync T3CODE_CLERK_JWT_TEMPLATE "$CLERK_JWT_TEMPLATE" |
| 149 | + sync T3CODE_CLERK_CLI_OAUTH_CLIENT_ID "$CLERK_CLI_OAUTH_CLIENT_ID" |
| 150 | + sync T3CODE_RELAY_URL "https://$relay_domain" |
| 151 | +
|
94 | 152 | - name: Pull production environment variables |
95 | 153 | if: steps.expo-token.outputs.present == 'true' |
96 | 154 | working-directory: apps/mobile |
97 | 155 | env: |
98 | 156 | EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} |
99 | 157 | run: eas env:pull production --non-interactive |
100 | 158 |
|
| 159 | + - name: Verify Connect config reaches the app manifest |
| 160 | + if: steps.expo-token.outputs.present == 'true' |
| 161 | + run: node scripts/verify-mobile-connect-config.ts |
| 162 | + |
101 | 163 | - name: Build and submit |
102 | 164 | if: steps.expo-token.outputs.present == 'true' && inputs.mode == 'build' |
103 | 165 | working-directory: apps/mobile |
|
0 commit comments