mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
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 [[ "${{ github.event.comment.body }}" == *"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 id: pr-info
79 uses: actions/github-script@v7
80 with:
81 script: |
82 const pr = await github.rest.pulls.get({
83 owner: context.repo.owner,
84 repo: context.repo.repo,
85 pull_number: ${{ github.event.issue.number }}
86 });
87
88 console.log(`PR HEAD SHA: ${pr.data.head.sha}`);
89 console.log(`PR HEAD REF: ${pr.data.head.ref}`);
90
91 core.setOutput('head-sha', pr.data.head.sha);
92 core.setOutput('head-ref', pr.data.head.ref);
93
94 - name: 💬 Drop a comment
95 uses: marocchino/sticky-pull-request-comment@v2
96 with:
97 header: pull-request-eas-build-${{ steps.pr-info.outputs.head-sha }}
98 number: ${{ github.event.issue.number }}
99 message: |
100 An OTA deployment has been requested and is now running for `${{ steps.pr-info.outputs.head-sha }}`.
101
102 [Here is some music to listen to while you wait...](https://www.youtube.com/watch?v=VBlFHuCzPgY)
103 ---
104 *Generated by [PR labeler](https://github.com/expo/expo/actions/workflows/pr-labeler.yml) 🤖*
105
106 - name: Check for EXPO_TOKEN
107 run: >
108 if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
109 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"
110 exit 1
111 fi
112
113 - name: ⬇️ Checkout
114 uses: actions/checkout@v4
115 with:
116 ref: ${{ steps.pr-info.outputs.head-sha }}
117
118 - name: 🔧 Setup Node
119 uses: actions/setup-node@v4
120 with:
121 node-version-file: .nvmrc
122 cache: yarn
123
124 - name: Install dependencies
125 run: yarn install --frozen-lockfile
126
127 - name: Lint check
128 run: yarn lint
129
130 - name: Lint lockfile
131 run: yarn lockfile-lint
132
133 - name: 🔤 Compile translations
134 run: yarn intl:build 2>&1 | tee i18n.log
135
136 - name: Check for i18n compilation errors
137 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
138
139 - name: Type check
140 run: yarn typecheck
141
142 - name: 🔨 Setup EAS
143 uses: expo/expo-github-action@v8
144 with:
145 expo-version: latest
146 eas-version: latest
147 token: ${{ secrets.EXPO_TOKEN }}
148
149 - name: ⛏️ Setup Expo
150 run: yarn global add eas-cli-local-build-plugin
151
152 - name: 🪛 Setup jq
153 uses: dcarbone/install-jq-action@v2
154
155 - name: Env
156 id: env
157 run: |
158 export json='${{ secrets.GOOGLE_SERVICES_TOKEN }}'
159 echo "${{ secrets.ENV_TOKEN }}" > .env
160 echo "EXPO_PUBLIC_ENV=testflight" >> .env
161 echo "EXPO_PUBLIC_RELEASE_VERSION=$(jq -r '.version' package.json)" >> .env
162 echo "EXPO_PUBLIC_RELEASE_VERSION=$(jq -r '.version' package.json)" >> $GITHUB_OUTPUT
163 echo "EXPO_PUBLIC_BUNDLE_IDENTIFIER=$(git rev-parse HEAD)" >> .env
164 echo "EXPO_PUBLIC_BUNDLE_IDENTIFIER=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
165 echo "EXPO_PUBLIC_BUNDLE_DATE=$(date -u +"%y%m%d%H")" >> .env
166 echo "EXPO_PUBLIC_SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> .env
167 echo "EXPO_PUBLIC_BITDRIFT_API_KEY=${{ secrets.BITDRIFT_API_KEY }}" >> .env
168 echo "EXPO_PUBLIC_GCP_PROJECT_ID=${{ secrets.EXPO_PUBLIC_GCP_PROJECT_ID }}" >> .env
169 echo "$json" > google-services.json
170
171 - name: 🏗️ Create Bundle
172 run: >
173 SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
174 SENTRY_RELEASE=${{ steps.env.outputs.EXPO_PUBLIC_RELEASE_VERSION }}
175 SENTRY_DIST=${{ steps.env.outputs.EXPO_PUBLIC_BUNDLE_IDENTIFIER }}
176 yarn export
177
178 - name: 📦 Package Bundle and 🚀 Deploy
179 run: yarn use-build-number bash scripts/bundleUpdate.sh
180 env:
181 DENIS_API_KEY: ${{ secrets.DENIS_API_KEY }}
182 CHANNEL_NAME: pull-request-${{ github.event.issue.number }}
183 RUNTIME_VERSION:
184
185 - name: 💬 Drop a comment
186 uses: marocchino/sticky-pull-request-comment@v2
187 with:
188 header: pull-request-eas-build-${{ steps.pr-info.outputs.head-sha }}
189 number: ${{ github.event.issue.number }}
190 message: |
191 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:
192
193 <img src="https://bsky-qr.vercel.app?channel=pull-request-${{ github.event.issue.number }}" width=300 height=300>
194
195 `bluesky://intent/apply-ota?channel=pull-request-${{ github.event.issue.number }}`
196 ---
197
198 *Generated by [PR labeler](https://github.com/expo/expo/actions/workflows/pr-labeler.yml) 🤖*
199
200 - name: 💬 Drop a comment
201 uses: marocchino/sticky-pull-request-comment@v2
202 if: failure()
203 with:
204 header: pull-request-eas-build-${{ steps.pr-info.outputs.head-sha }}
205 number: ${{ github.event.issue.number }}
206 message: |
207 Your requested OTA deployment was unsuccessful. See action logs for more details.
208 ---
209 *Generated by [PR labeler](https://github.com/expo/expo/actions/workflows/pr-labeler.yml) 🤖*