-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (133 loc) · 4.29 KB
/
build.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
name: 'Build'
on:
push:
branches:
- main
pull_request:
jobs:
dependencies:
name: Install and cache dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'yarn'
- uses: actions/cache@v3
id: cache-deps
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: yarn install
check-types:
name: Check types
runs-on: ubuntu-latest
needs: dependencies
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'yarn'
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Run yarn check-types
run: yarn check-types
lint:
name: Run eslint
runs-on: ubuntu-latest
needs: dependencies
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'yarn'
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Run yarn lint
run: yarn lint
test:
name: Run tests
runs-on: ubuntu-latest
needs: dependencies
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'yarn'
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Run yarn test
run: yarn test
create-preview:
name: Create Expo preview
runs-on: ubuntu-latest
needs: [check-types, lint, test]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
cache: 'yarn'
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Check for EXPO_TOKEN
run: |
if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then
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"
exit 1
fi
- name: Setup EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Publish preview to Expo
run: eas update --auto --non-interactive --json > build.json
create-preview-comment:
name: Create Expo preview comment
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
needs: create-preview
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Extract build IDs from build.json
run: |
android_id=$(cat build.json | jq -r 'map(select(has("platform") and .platform == "android")) | .[0].id')
ios_id=$(cat build.json | jq -r 'map(select(has("platform") and .platform == "ios")) | .[0].id')
echo "ANDROID_ID=$android_id" >> $GITHUB_ENV
echo "IOS_ID=$ios_id" >> $GITHUB_ENV
- name: Post comment
uses: unsplash/comment-on-pr@v1.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
msg: |
Preview builds were successfully created:
| Android | iOS |
| --- | --- |
| ![Android QR Code](https://qr.expo.dev/eas-update?updateId=${{ env.ANDROID_ID }}&appScheme=exp&host=u.expo.dev) | ![iOS QR Code](https://qr.expo.dev/eas-update?updateId=${{ env.IOS_ID }}&appScheme=exp&host=u.expo.dev) |
check_for_duplicate_msg: false
delete_prev_regex_msg: 'Preview builds were successfully created:'