forked from WorldHealthOrganization/app
-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (198 loc) · 7.7 KB
/
client.yaml
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
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Client CI
env:
FLUTTER_VERSION: "1.22.1"
on:
push:
paths:
- ".github/workflows/**"
- "api/**"
- "client/**"
- "docs/**"
- "tools/**"
- "LICENSE"
pull_request:
branches: [master]
paths:
- ".github/workflows/**"
- "api/**"
- "client/**"
- "docs/**"
- "tools/**"
- "LICENSE"
jobs:
test:
name: Test client on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- run: git clone https://github.com/flutter/flutter.git --depth 1 -b $FLUTTER_VERSION _flutter
- run: echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH
- run: flutter doctor -v
- run: flutter pub get
working-directory: ./client
- run: flutter analyze --no-pub
working-directory: ./client
- run: flutter format lib/** --set-exit-if-changed
working-directory: ./client
- run: flutter test --no-pub
working-directory: ./client
autogen_update_check:
name: Check auto-generated client files are up-to-date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: git clone https://github.com/flutter/flutter.git --depth 1 -b $FLUTTER_VERSION _flutter
- run: echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH
- run: flutter doctor -v
- run: flutter pub get
working-directory: ./client
- run: echo PHASE 1 - Ensure auto-gened MobX stores
- run: flutter packages pub run build_runner build --delete-conflicting-outputs
working-directory: ./client
- run: flutter format lib/**
working-directory: ./client
- run: git diff --exit-code
- run: echo PHASE 2 - Ensure auto-gened protocol buffers
- run: sudo apt install -y protobuf-compiler
- run: protoc --version
- run: flutter pub global activate protoc_plugin ^19.0.1
working-directory: ./client
- run: echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
- run: ./tools/gen-client-protos.sh
- run: flutter format lib/**
working-directory: ./client
- run: git diff --exit-code
build_ios:
name: Build iOS app
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- run: git clone https://github.com/flutter/flutter.git --depth 1 -b $FLUTTER_VERSION _flutter
- run: echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH
- run: flutter doctor -v
- run: flutter pub get
working-directory: ./client
- run: flutter build ios --release --no-codesign
working-directory: ./client
- run: git diff --exit-code
build_android:
# Firebase requires fat APKs, not AABs.
name: Build Android APK (Staging)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: "11.0.9"
- run: git clone https://github.com/flutter/flutter.git --depth 1 -b $FLUTTER_VERSION _flutter
- run: echo "$GITHUB_WORKSPACE/_flutter/bin" >> $GITHUB_PATH
- run: flutter doctor -v
- run: flutter pub get
working-directory: ./client
- run: git diff --exit-code
- run: DEVELOPMENT_ONLY=true ./tools/gen-client-buildinfo.sh
- run: flutter build appbundle
working-directory: ./client
# TODO: generate apk from appbundle using bundletool
- run: flutter build apk
working-directory: ./client
- name: Upload Staging APK artifact
uses: actions/upload-artifact@v2
with:
name: staging-apk
path: ./client/build/app/outputs/apk/release/app-release.apk
deploy_apk_to_firebase_staging:
name: Deploy APK to Firebase App Distribution (Staging)
runs-on: ubuntu-latest
needs:
- build_android
- test
# SECURITY: This job uses staging secrets; do not enable it for
# pull requests.
if: |
github.repository == 'WorldHealthOrganization/app' &&
github.ref == 'refs/heads/master' &&
github.event_name == 'push'
env:
FIREBASE_STAGING_APP_ID: "1:1057717871229:android:4fbe832a3de230450dc714"
LOG_URL: "https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
steps:
- uses: actions/checkout@v2
- name: Download Staging APK Artifact
uses: actions/download-artifact@v2
with:
name: staging-apk
path: tools
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 12
- name: Install Firebase CLI
run: npm install
working-directory: ./tools
- name: Setup Firebase Credentials
shell: bash
run: |
echo "$BASE64_KEY_JSON" | base64 --decode > $GOOGLE_APPLICATION_CREDENTIALS_GPG
gpg --quiet --batch --yes --decrypt --passphrase="$KEY_PASSPHRASE" --output $GOOGLE_APPLICATION_CREDENTIALS $GOOGLE_APPLICATION_CREDENTIALS_GPG
rm $GOOGLE_APPLICATION_CREDENTIALS_GPG
env:
BASE64_KEY_JSON: "${{ secrets.FIREBASE_APPDEPLOY_STAGING_SVCACCT_JSON }}"
KEY_PASSPHRASE: "${{ secrets.FIREBASE_APPDEPLOY_STAGING_SVCACCT_PASSPHRASE }}"
GOOGLE_APPLICATION_CREDENTIALS: "${{ runner.temp }}/fbappdeploy.json"
GOOGLE_APPLICATION_CREDENTIALS_GPG: "${{ runner.temp }}/fbappdeploy.json.gpg"
- id: newDeployment
name: Track Environment Deployment Status
uses: actions/github-script@v2
with:
previews: flash,ant-man
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { data: deployment } = await github.repos.createDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.sha,
auto_merge: false,
environment: 'firebase-staging-android',
required_contexts: [],
});
await github.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: deployment.id,
state: 'in_progress',
log_url: process.env.LOG_URL,
});
return deployment.id;
- name: Run Firebase App Distribution
shell: bash
run: |
npx firebase appdistribution:distribute --app "$FIREBASE_STAGING_APP_ID" --release-notes "$RELEASE_NOTES" --groups "every-build" app-release.apk
env:
GOOGLE_APPLICATION_CREDENTIALS: "${{ runner.temp }}/fbappdeploy.json"
RELEASE_NOTES: "https://github.com/${{ github.repository }}/tree/${{ github.sha }} . Any prior version of this app will need to be uninstalled prior to installing this build."
working-directory: ./tools
- name: Destroy Firebase Credentials
run: rm $GOOGLE_APPLICATION_CREDENTIALS
if: ${{ always() }}
env:
GOOGLE_APPLICATION_CREDENTIALS: "${{ runner.temp }}/fbappdeploy.json"
- uses: actions/github-script@v2
name: Finalize Deployment Status
if: ${{ always() }}
with:
previews: flash,ant-man
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
await github.repos.createDeploymentStatus({
owner: context.repo.owner,
repo: context.repo.repo,
deployment_id: '${{steps.newDeployment.outputs.result}}',
state: '${{job.status}}' === 'success' ? 'success' : 'failure',
log_url: process.env.LOG_URL,
environment_url: '${{job.status}}' === 'success' ? 'https://console.firebase.google.com/project/who-myhealth-staging/appdistribution/app/android:org.who.WHOMyHealth/releases' : '',
auto_inactive: '${{job.status}}' === 'success'
});