Open History to see the last commit
1name: Mobile EAS Preview (Fork)
2
3# EAS previews for fork PRs. This runs the PR's code with an Expo token: the
4# app config and plugins run on this runner, and native builds run on EAS
5# with preview signing credentials. The label is the maintainer's sign-off
6# that they reviewed that code, so it covers exactly the commit it was applied
7# to: this pins that commit and consumes the label before running anything. A
8# later push deploys nothing until the label is applied again.
9#
10# Same-repo PRs deploy on every push while labeled, via mobile-eas-preview.yml.
11
12on:
13 pull_request_target:
14 types: [labeled]
15
16permissions:
17 contents: read
18
19jobs:
20 preview:
21 name: EAS Preview
22 if: >-
23 github.event.pull_request.head.repo.full_name != github.repository &&
24 github.event.label.name == '🚀 Mobile Continuous Deployment'
25 runs-on: blacksmith-8vcpu-ubuntu-2404
26 concurrency:
27 group: mobile-eas-preview-fork-${{ github.event.pull_request.number }}
28 cancel-in-progress: true
29 permissions:
30 contents: read
31 pull-requests: write
32 env:
33 APP_VARIANT: preview
34 NODE_OPTIONS: --max-old-space-size=8192
35 MOBILE_VERSION_POLICY: fingerprint
36 steps:
37 # If a maintainer removed the label first, that removal wins.
38 - id: consume
39 name: Consume the deployment label
40 uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
41 with:
42 script: |
43 try {
44 await github.rest.issues.removeLabel({
45 owner: context.repo.owner,
46 repo: context.repo.repo,
47 issue_number: context.payload.pull_request.number,
48 name: context.payload.label.name,
49 });
50 core.setOutput("consumed", "true");
51 } catch (error) {
52 if (error.status !== 404) throw error;
53 core.info("The label was removed before this run could consume it. Skipping.");
54 core.setOutput("consumed", "false");
55 }
56
57 - id: expo-token
58 name: Check for EXPO_PREVIEW_TOKEN
59 if: steps.consume.outputs.consumed == 'true'
60 env:
61 EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
62 run: |
63 if [ -n "$EXPO_TOKEN" ]; then
64 echo "present=true" >> "$GITHUB_OUTPUT"
65 else
66 echo "present=false" >> "$GITHUB_OUTPUT"
67 echo "EXPO_PREVIEW_TOKEN is not set; skipping EAS preview."
68 fi
69
70 # The head SHA from the label event, not the branch, so a push after the
71 # label cannot swap in unreviewed code. No credentials stay in .git for
72 # the PR's scripts to read.
73 - name: Checkout reviewed commit
74 if: steps.expo-token.outputs.present == 'true'
75 uses: actions/checkout@v6
76 with:
77 ref: ${{ github.event.pull_request.head.sha }}
78 fetch-depth: 0
79 persist-credentials: false
80 # No sparse-checkout: see mobile-eas-preview.yml.
81
82 # No caches: pull_request_target saves them under main's scope, where
83 # trusted workflows with other secrets would restore what PR code wrote.
84 - name: Setup Vite+
85 if: steps.expo-token.outputs.present == 'true'
86 uses: voidzero-dev/setup-vp@v1
87 with:
88 node-version-file: package.json
89 cache: false
90 run-install: |
91 args:
92 - --filter=@t3tools/mobile...
93
94 - name: Expose pnpm
95 if: steps.expo-token.outputs.present == 'true'
96 run: |
97 pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
98 vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
99 echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
100 "$vp_pnpm_bin/pnpm" --version
101
102 - name: Setup EAS
103 if: steps.expo-token.outputs.present == 'true'
104 uses: expo/expo-github-action@v8
105 with:
106 # Pinned and installed with npm for the same reasons as mobile-eas-preview.yml.
107 eas-version: 21.8.0
108 eas-cache: false
109 token: ${{ secrets.EXPO_PREVIEW_TOKEN }}
110 packager: npm
111
112 - name: Pull preview environment variables
113 if: steps.expo-token.outputs.present == 'true'
114 working-directory: apps/mobile
115 env:
116 EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
117 run: |
118 eas env:pull preview --non-interactive
119 # See mobile-eas-preview.yml: keeps Android build and OTA fingerprints matching.
120 node --input-type=module <<'NODE'
121 import { appendFileSync, readFileSync } from "node:fs";
122 import { parseEnv } from "node:util";
123 const env = parseEnv(readFileSync(".env.local", "utf8"));
124 const googleServicesFile = env.T3CODE_ANDROID_GOOGLE_SERVICES_FILE;
125 if (googleServicesFile) {
126 appendFileSync(process.env.GITHUB_ENV, `T3CODE_ANDROID_GOOGLE_SERVICES_FILE=${googleServicesFile}\n`);
127 }
128 NODE
129
130 - name: Deploy with fingerprint check
131 if: steps.expo-token.outputs.present == 'true'
132 uses: expo/expo-github-action/continuous-deploy-fingerprint@main
133 env:
134 EXPO_TOKEN: ${{ secrets.EXPO_PREVIEW_TOKEN }}
135 RUNNER_DEBUG: "1"
136 # The action only comments for pull_request events; this hook gives
137 # it the PR under pull_request_target. Without it, it skips the comment.
138 EXPO_TEST_GITHUB_PULL: ${{ github.event.pull_request.number }}
139 with:
140 profile: preview:dev
141 branch: pr-${{ github.event.pull_request.number }}
142 platform: all
143 environment: preview
144 working-directory: apps/mobile
145 github-token: ${{ secrets.GITHUB_TOKEN }}