-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (202 loc) · 6.97 KB
/
build_task.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: CI
on:
push:
branches: [ master ]
paths-ignore:
- firebase/**
pull_request:
branches: [ master ]
paths-ignore:
- firebase/**
# add [skip ci] to pull_request title to skip ci check!
jobs:
analyze:
if: ${{ !contains(github.event.pull_request.title, '[skip ci]') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
with:
flutter-version: '1.17.0'
channel: 'stable'
- name: Flutter analyze
run: ./scripts/analyze.sh
- name: Cache bundle
uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gem-
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.1
- name: Danger
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gem install bundler
bundle install
bundle exec danger
build-android:
if: ${{ !contains(github.event.pull_request.title, '[skip ci]') }}
runs-on: ubuntu-latest
needs: [analyze]
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
with:
flutter-version: '1.17.0'
channel: 'stable'
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Pub get
run: flutter pub get
- name: Generate google-services.json
env:
GOOGLE_SERVICES_BASE64: ${{ secrets.GOOGLE_SERVICES_BASE64 }}
run: echo $GOOGLE_SERVICES_BASE64 | base64 --decode --ignore-garbage > $GITHUB_WORKSPACE/android/app/google-services.json
- name: Android build
run: flutter build apk --release
- uses: actions/upload-artifact@v2
with:
name: generated_apk
path: ./build/app/outputs/apk/release/app-release.apk
- name: Create file failure.txt and write 'true' into it
if: always()
run: echo ${{ job.status == 'failure' }} > failure.txt
- name: Upload file about failure
if: always()
uses: actions/upload-artifact@v1
with:
name: pass_file
path: failure.txt
build-ios:
if: ${{ !contains(github.event.pull_request.title, '[skip ci]') }}
runs-on: macos-latest
needs: [analyze]
steps:
- uses: actions/checkout@v2
- uses: subosito/flutter-action@v1
with:
flutter-version: '1.17.0'
channel: 'stable'
- uses: actions/cache@v1
with:
path: ios/Pods
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Pub get
run: flutter pub get
- name: Generate GoogleService-Info.plist
env:
GOOGLE_SERVICE_INFO_BASE64: ${{ secrets.GOOGLE_SERVICE_INFO_BASE64 }}
run: echo $GOOGLE_SERVICE_INFO_BASE64 | base64 --decode > $GITHUB_WORKSPACE/ios/Runner/GoogleService-Info.plist
- name: iOS build
run: flutter build ios --release --no-codesign
# TODO: upload ipa
- name: Create file failure.txt and write 'true' into it
if: always()
run: echo ${{ job.status == 'failure' }} > failure.txt
- name: Upload file about failure
if: always()
uses: actions/upload-artifact@v1
with:
name: pass_file
path: failure.txt
distribute_app:
needs: [build-android, build-ios]
if: ${{ !contains(github.event.pull_request.title, '[skip ci]') }} && always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Cache bundle
uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gem-
- name: Cache npm
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.1
- name: Setup Bundler
run: gem install bundler
- name: Bundle install
run: bundle install --path vendor/bundle
- name: npm ci
run: npm ci
working-directory: ./firebase
- name: Download apk
uses: actions/download-artifact@v2
with:
name: generated_apk
- name: Distribute Android App
env:
FIREBASE_APP_ID_ANDROID: ${{ secrets.FIREBASE_APP_ID_ANDROID }}
FIREBASE_CLI_TOKEN: ${{ secrets.FIREBASE_CLI_TOKEN }}
APK_PATH: ./app-release.apk
RELEASE_NOTE: ${{ github.head_ref }}
run: bundle exec fastlane android distribute_app
notification:
needs: [distribute_app]
if: ${{ !contains(github.event.pull_request.title, '[skip ci]') }} && always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Download file post_message.txt
uses: actions/download-artifact@v1
with:
name: pass_file
- name: Read file failure.txt and set output parameter
id: set_output
run: echo "::set-output name=failure::$(<pass_file/failure.txt)"
- name: get commit message
id: set_commitmsg
run: echo "::set-output name=commitmsg::$(git log --format=%B -n 1 ${{ github.event.after }})"
# 失敗したときのSlackへの通知
- name: Slack Notification Failure
if: steps.set_output.outputs.failure == 'true'
uses: rtCamp/[email protected]
env:
SLACK_CHANNEL: gotties-log
SLACK_ICON: https://github.com/actions.png?size=48
SLACK_COLOR: '#ff0000'
SLACK_TITLE: ':fire: Build Failure :fire:'
SLACK_MESSAGE: |
Build failure!
See more detail to check github.
commit -> `${{ steps.set_commitmsg.outputs.commitmsg }}`
SLACK_USERNAME: Github Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
# 成功した時のSlackへの通知
- name: Slack Notification Success
if: steps.set_output.outputs.failure != 'true'
uses: rtCamp/[email protected]
env:
SLACK_CHANNEL: gotties-log
SLACK_ICON: https://github.com/actions.png?size=48
SLACK_TITLE: ':rocket: Build Success :rocket:'
SLACK_MESSAGE: |
Build success! yattane!
commit -> `${{ steps.set_commitmsg.outputs.commitmsg }}`
SLACK_USERNAME: Github Actions
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}