This repository has been archived by the owner on Aug 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
185 lines (180 loc) · 7.6 KB
/
deploy_branch_preview.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
name: Deploy Branch Preview
on: [pull_request]
# Ensure only a single job or workflow using the same concurrency group will run at a time
# When a concurrent job or workflow is queued, if another job or workflow using the same concurrency group in the repository is in progress,
# the queued job or workflow will be pending.
concurrency:
group: ${{ github.ref }}-deploy-branch-preview # The branch or tag ref that triggered the workflow run.
jobs:
pr_title_lint:
name: PR Title Lint
runs-on: ubuntu-latest
continue-on-error: false
timeout-minutes: 5
steps:
- name: check if PR title follows conventional commits specs
uses: amannn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}
# using github token for external/dependabot PR,
# personal access tokens in secrets will not be accessible in
# pipeline for external user PRs
markdown_lint:
name: Markdown Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v4
with:
node-version: 16.x
- name: Install Packages
run: |
npm config set //npm.pkg.github.com/:_authToken $NPM_TOKEN
npm ci
env:
NPM_TOKEN: ${{ secrets.GH_TOKEN_SUPPLYALLY_BOT }}
- name: Check Markdown Lint
run: npm run markdown:lint
test:
name: Lint & Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v4
with:
node-version: 16.x
- name: Cache Node Modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Packages
run: |
npm config set //npm.pkg.github.com/:_authToken $NPM_TOKEN
npm ci --legacy-peer-deps
env:
NPM_TOKEN: ${{ secrets.GH_TOKEN_SUPPLYALLY_BOT }}
- name: Typecheck
run: npx --no-install tsc --noEmit
- name: Check Lint
run: npm run lint
- name: Set Timezone to +8 (Ubuntu)
run: sudo timedatectl set-timezone Asia/Singapore
- name: Test
run: npm run test -- --coverage
env:
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
APP_BUILD_VERSION: ${{ github.run_number }}
APP_BINARY_VERSION: "dev"
DOMAIN_FORMAT: ${{ secrets.TEST_DOMAIN_FORMAT }}
PROJECT_ID: ${{ secrets.EXPO_TEST_PROJECT_ID }}
OWNER: ${{ secrets.EXPO_TEST_OWNER }}
deploy_branch_preview:
name: Deploy Branch Preview
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Fetch Tags
run: |
git fetch --prune --unshallow --tags -f
- uses: actions/setup-node@v4
with:
node-version: 16.x
- uses: expo/expo-github-action@v8
with:
eas-version: 3.12.0
expo-version: 6.3.9
packager: npm
token: ${{ secrets.EXPO_TOKEN }}
eas-cache: true
expo-cache: true
- name: Cache Node Modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Packages
run: |
npm config set //npm.pkg.github.com/:_authToken $NPM_TOKEN
npm ci --legacy-peer-deps
env:
NPM_TOKEN: ${{ secrets.GH_TOKEN_SUPPLYALLY_BOT }}
- name: Get Latest Binary Version # Binary Version will be x.x.x based on the latest tag
run: |
# Release tag finds the latest tag in the tree branch - i.e. prod-x.x.x
RELEASE_TAG=$(echo $(git describe --tags --abbrev=0))
# Using param substitution, we output x.x.x instead
echo "LATEST_BINARY_VERSION=${RELEASE_TAG#*-}" >> "$GITHUB_ENV"
- name: Echo Version Details
run: |
echo Build number is $GITHUB_RUN_NUMBER
echo Latest release is ${{ env.LATEST_BINARY_VERSION }}
- name: Get commit message
run: |
MSG=$(git log --format=%B -n 1 ${{github.event.after}})
echo "COMMIT_MESSAGE=${MSG}" >> "$GITHUB_ENV"
- name: Eas Update Channel
env:
NODE_OPTIONS: --max_old_space_size=7168
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
APP_BUILD_VERSION: ${{ github.run_number }}
APP_BINARY_VERSION: ${{ env.LATEST_BINARY_VERSION}}
DOMAIN_FORMAT: ${{ secrets.TEST_DOMAIN_FORMAT }}
PROJECT_ID: ${{ secrets.EXPO_TEST_PROJECT_ID }}
OWNER: ${{ secrets.EXPO_TEST_OWNER }}
run: |
.github/scripts/inject-token.sh
eas update --non-interactive --branch pr${{ github.event.number }} --message "${{ env.COMMIT_MESSAGE }}"
- name: Preview Deep Link
run: echo "APPLICATION_URL=https://u.expo.dev/${{ secrets.EXPO_TEST_PROJECT_ID }}?channel-name=pr${{ github.event.number }}" >> "$GITHUB_ENV"
- name: Eas Update Storybook Channel
env:
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
APP_BUILD_VERSION: ${{ github.run_number }}
APP_BINARY_VERSION: ${{ env.LATEST_BINARY_VERSION }}
DOMAIN_FORMAT: ${{ secrets.TEST_DOMAIN_FORMAT }}
PROJECT_ID: ${{ secrets.EXPO_TEST_PROJECT_ID }}
OWNER: ${{ secrets.EXPO_TEST_OWNER }}
START_STORYBOOK: "true"
run: |
.github/scripts/inject-token.sh
eas update --non-interactive --branch storybook-pr${{ github.event.number }} --message "${{ env.COMMIT_MESSAGE }}"
- name: Preview Storybook Deep Link
run: echo "STORYBOOK_URL=https://u.expo.dev/${{ secrets.EXPO_TEST_PROJECT_ID }}?channel-name=storybook-pr${{ github.event.number }}" >> "$GITHUB_ENV"
- name: Add Comment To PR
uses: mshick/add-pr-comment@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_SUPPLYALLY_BOT }}
with:
message: |
## Application
![Expo QR](https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=exp%2Brationally://expo-development-client/?url=${{ env.APPLICATION_URL }})
OR Enter this link into your dev client: `exp+rationally://expo-development-client/?url=${{ env.APPLICATION_URL }}`
## Storybook
![Expo QR](https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=exp%2Brationally://expo-development-client/?url=${{ env.STORYBOOK_URL }})
OR Enter this link into your dev client: `exp+rationally://expo-development-client/?url=${{ env.STORYBOOK_URL }}`