forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 💫
1---
2name: PR Comment Trigger
3
4on:
5 issue_comment:
6 types: [created]
7
8# Permissiosn to make comments in the pull request
9permissions:
10 pull-requests: write
11 actions: write
12 contents: read
13
14jobs:
15 handle-comment:
16 if: github.event.issue.pull_request
17 runs-on: ubuntu-latest
18 outputs:
19 should-deploy: ${{ steps.check-org.outputs.result }}
20
21 steps:
22 - name: Check if bot is mentioned
23 id: check-mention
24 env:
25 COMMENT: ${{ github.event.comment.body }}
26 run: |
27 if [[ "$COMMENT" == *"@github-actions"* ]] || \
28 [[ "$COMMENT" == *"github-actions[bot]"* ]]; then
29 bot_mentioned=true
30 else
31 bot_mentioned=false
32 fi
33
34
35 if [[ "$COMMENT" == *"ota"* ]]; then
36 has_ota=true
37 else
38 has_ota=false
39 fi
40
41
42 if [[ "$bot_mentioned" == "true" ]] && [[ "$has_ota" == "true" ]]; then
43 echo "mentioned=true" >> $GITHUB_OUTPUT
44 else
45 echo "mentioned=false" >> $GITHUB_OUTPUT
46 fi
47
48 - name: Check organization membership
49 if: steps.check-mention.outputs.mentioned == 'true'
50 id: check-org
51 uses: actions/github-script@v7
52 with:
53 script: |
54 try {
55 const { data: perm } = await github.rest.repos.getCollaboratorPermissionLevel({
56 owner: context.repo.owner,
57 repo: context.repo.repo,
58 username: context.payload.comment.user.login
59 });
60
61 const hasAccess = ['admin', 'write'].includes(perm.permission);
62 console.log(`User has ${perm.permission} access`);
63
64 return hasAccess;
65 } catch(error) {
66 console.log('User has no repository access');
67 return false;
68 }
69
70 bundle-deploy:
71 name: Bundle and Deploy EAS Update
72 runs-on: ubuntu-latest
73 needs: [handle-comment]
74 if: needs.handle-comment.outputs.should-deploy == 'true'
75
76 steps:
77 - name: Get PR HEAD SHA
78 env:
79 ISSUE_NUMBER: ${{ github.event.issue.number }}
80 id: pr-info
81 uses: actions/github-script@v7
82 with:
83 script: |
84 const pr = await github.rest.pulls.get({
85 owner: context.repo.owner,
86 repo: context.repo.repo,
87 pull_number: process.env.ISSUE_NUMBER,
88 });
89
90 console.log(`PR HEAD SHA: ${pr.data.head.sha}`);
91 console.log(`PR HEAD REF: ${pr.data.head.ref}`);
92
93 core.setOutput('head-sha', pr.data.head.sha);
94 core.setOutput('head-ref', pr.data.head.ref);
95
96 - name: 💬 Drop a comment
97 uses: marocchino/sticky-pull-request-comment@v2
98 with:
99 header: pull-request-eas-build-${{ steps.pr-info.outputs.head-sha }}
100 number: ${{ github.event.issue.number }}
101 message: |
102 An OTA deployment has been requested and is now running for `${{ steps.pr-info.outputs.head-sha }}`.
103
104 [Here is some music to listen to while you wait...](https://www.youtube.com/watch?v=VBlFHuCzPgY)
105 ---
106 *Generated by [PR labeler](https://github.com/expo/expo/actions/workflows/pr-labeler.yml) 🤖*
107
108 - name: Check for EXPO_TOKEN
109 run: >
110 if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
111 echo "You must provide an EXPO_TOKEN secret linked to this project's Expo account in this repo's secrets. Learn more: https://docs.expo.dev/eas-update/github-actions"
112 exit 1
113 fi
114
115 - name: ⬇️ Checkout
116 uses: actions/checkout@v4
117 with:
118 ref: ${{ steps.pr-info.outputs.head-sha }}
119
120 - name: 🔧 Setup Node
121 uses: actions/setup-node@v6
122 with:
123 node-version-file: .nvmrc
124 cache: yarn
125
126 - name: Install dependencies
127 run: yarn install --frozen-lockfile
128
129 - name: Lint check
130 run: yarn lint
131
132 - name: Lint lockfile
133 run: yarn lockfile-lint
134
135 - name: 🔤 Compile translations
136 run: yarn intl:build 2>&1 | tee i18n.log
137
138 - name: Check for i18n compilation errors
139 run: if grep -q "invalid syntax" "i18n.log"; then echo "\n\nFound compilation errors!\n\n" && exit 1; else echo "\n\nNo compilation errors!\n\n"; fi
140
141 - name: Type check
142 run: yarn typecheck
143
144 - name: 🔨 Setup EAS
145 uses: expo/expo-github-action@main
146 with:
147 expo-version: latest
148 eas-version: latest
149 token: ${{ secrets.EXPO_TOKEN }}
150
151 - name: ⛏️ Setup Expo
152 run: yarn global add eas-cli-local-build-plugin
153
154 - name: 🪛 Setup jq
155 uses: dcarbone/install-jq-action@v2
156
157 - name: Env
158 id: env
159 run: |
160 export json='${{ secrets.GOOGLE_SERVICES_TOKEN }}'
161 echo "${{ secrets.ENV_TOKEN }}" > .env
162 echo "EXPO_PUBLIC_ENV=testflight" >> .env
163 echo "EXPO_PUBLIC_RELEASE_VERSION=$(jq -r '.version' package.json)" >> .env
164 echo "EXPO_PUBLIC_RELEASE_VERSION=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT
165 echo "EXPO_PUBLIC_BUNDLE_IDENTIFIER=$(git rev-parse HEAD)" >> .env
166 echo "EXPO_PUBLIC_BUNDLE_IDENTIFIER=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
167 echo "EXPO_PUBLIC_BUNDLE_DATE=$(date -u +"%y%m%d%H")" >> .env
168 echo "EXPO_PUBLIC_SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> .env
169 echo "EXPO_PUBLIC_BITDRIFT_API_KEY=${{ secrets.BITDRIFT_API_KEY }}" >> .env
170 echo "EXPO_PUBLIC_GCP_PROJECT_ID=${{ secrets.EXPO_PUBLIC_GCP_PROJECT_ID }}" >> .env
171 echo "$json" > google-services.json
172
173 - name: 🏗️ Create Bundle
174 run: >
175 SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
176 SENTRY_RELEASE=${{ steps.env.outputs.EXPO_PUBLIC_RELEASE_VERSION }}
177 SENTRY_DIST=${{ steps.env.outputs.EXPO_PUBLIC_BUNDLE_IDENTIFIER }}
178 yarn export
179
180 - name: 📦 Package Bundle and 🚀 Deploy
181 run: yarn use-build-number bash scripts/bundleUpdate.sh
182 env:
183 DENIS_API_KEY: ${{ secrets.DENIS_API_KEY }}
184 CHANNEL_NAME: pull-request-${{ github.event.issue.number }}
185 RUNTIME_VERSION:
186
187 - name: 💬 Drop a comment
188 uses: marocchino/sticky-pull-request-comment@v2
189 env:
190 ISSUE_NUMBER: ${{ github.event.issue.number }}
191 with:
192 header: pull-request-eas-build-${{ steps.pr-info.outputs.head-sha }}
193 number: ${{ github.event.issue.number }}
194 message: |
195 Your requested OTA deployment was successful! You may now apply it by either scanning the QR code or opening the deep link below in your browser:
196
197 <img src="https://bsky-qr.vercel.app?channel=pull-request-$ISSUE_NUMBER" width=300 height=300>
198
199 `bluesky://intent/apply-ota?channel=pull-request-${{ github.event.issue.number }}`
200 ---
201
202 *Generated by [PR labeler](https://github.com/expo/expo/actions/workflows/pr-labeler.yml) 🤖*
203
204 - name: 💬 Drop a comment
205 uses: marocchino/sticky-pull-request-comment@v2
206 if: failure()
207 with:
208 header: pull-request-eas-build-${{ steps.pr-info.outputs.head-sha }}
209 number: ${{ github.event.issue.number }}
210 message: |
211 Your requested OTA deployment was unsuccessful. See action logs for more details.
212 ---
213 *Generated by [PR labeler](https://github.com/expo/expo/actions/workflows/pr-labeler.yml) 🤖*