-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (173 loc) · 6.61 KB
/
Android_Develop_PR_CD.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
name: Android PR Builder
on:
pull_request:
types:
- closed
branches: [ an/develop ]
defaults:
run:
working-directory: ./android
jobs:
ktlintCheck:
name: ktLint Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run ktLint Check
uses: ./.github/actions/ktlint_check
with:
POKE_BASE_URL: ${{ secrets.POKE_BASE_URL }}
testAlphaUnitTest:
name: Test Alpha Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Gradle cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Create Google-Services.json
env:
GOOGLE_SERVICES_ALPHA: ${{ secrets.GOOGLE_SERVICES_ALPHA }}
GOOGLE_SERVICES_BETA: ${{ secrets.GOOGLE_SERVICES_BETA }}
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
run: |
touch ./app/src/debug/google-services.json
touch ./app/src/alpha/google-services.json
touch ./app/src/beta/google-services.json
mkdir ./app/src/release
touch ./app/src/release/google-services.json
echo $GOOGLE_SERVICES_ALPHA >> ./app/src/debug/google-services.json
echo $GOOGLE_SERVICES_ALPHA >> ./app/src/alpha/google-services.json
echo $GOOGLE_SERVICES_BETA >> ./app/src/beta/google-services.json
echo $GOOGLE_SERVICES >> ./app/src/release/google-services.json
- name: Create Local Properties
run: touch local.properties
- name: Access Local Properties
env:
POKE_BASE_URL: ${{ secrets.POKE_BASE_URL }}
run: |
echo POKE_BASE_URL=\"${{ secrets.POKE_BASE_URL }}\" >> local.properties
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: run alpha unit test
run: ./gradlew testAlphaUnitTest
Distribution:
name: Alpha APK to Discord
runs-on: ubuntu-latest
needs: [ ktlintCheck, testAlphaUnitTest ]
steps:
- uses: actions/checkout@v4
- name: Gradle cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Create Google-Services.json
env:
GOOGLE_SERVICES_ALPHA: ${{ secrets.GOOGLE_SERVICES_ALPHA }}
GOOGLE_SERVICES_BETA: ${{ secrets.GOOGLE_SERVICES_BETA }}
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
run: |
touch ./app/src/debug/google-services.json
touch ./app/src/alpha/google-services.json
touch ./app/src/beta/google-services.json
mkdir ./app/src/release
touch ./app/src/release/google-services.json
echo $GOOGLE_SERVICES_ALPHA >> ./app/src/debug/google-services.json
echo $GOOGLE_SERVICES_ALPHA >> ./app/src/alpha/google-services.json
echo $GOOGLE_SERVICES_BETA >> ./app/src/beta/google-services.json
echo $GOOGLE_SERVICES >> ./app/src/release/google-services.json
- name: Check google-services.json content
run: cat ./app/src/debug/google-services.json
- name: Create Local Properties
run: touch local.properties
- name: Access Local Properties
env:
POKE_BASE_URL: ${{ secrets.POKE_BASE_URL }}
# POKE_RELEASE_URL: ${{ secrets.HOST_RELEASE_URI }}
# KEYSTORE_PATH: ${{ secrets.KEYSTORE_PATH }}
# STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }}
# KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
# KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
# STORE_FILE: ${{ secrets.STORE_FILE }}
run: |
echo POKE_BASE_URL=\"${{ secrets.POKE_BASE_URL }}\" >> local.properties
# echo STORE_PASSWORD= $STORE_PASSWORD >> local.properties
# echo KEY_PASSWORD= $KEY_PASSWORD >> local.properties
# echo KEY_ALIAS= $KEY_ALIAS >> local.properties
# echo STORE_FILE= $STORE_FILE >> local.properties
# - name: Create Key Store
# env:
# KEY_STORE_BASE_64: ${{secrets.KEY_STORE_BASE_64}}
# run: |
# echo "$KEY_STORE_BASE_64" | base64 -d > ./funch_key_store.jks
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build alpha APK
run: ./gradlew assembleAlpha
- name: Upload alpha APK artifact
uses: actions/upload-artifact@v4
with:
name: android-artifact
path: android/app/build/outputs/apk/alpha/
if-no-files-found: error
- name: Check APK existence
run: ls -al app/build/outputs/apk/alpha/
- name: Extract Version Name
env:
title: ${{ github.event.pull_request.title }}
run: |
version=$(echo '${{ env.title }}' | grep -oP '\d+\.\d+\.\d+')
echo "version=v$version" >> $GITHUB_ENV
- name: Send alpha version APK to Discord with Embeds
env:
DISCORD_WEBHOOK_URL: ${{ secrets.AlPHA_APK_DISCORD_WEB_HOOK }}
VERSION: ${{ env.version }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: |
CONTENT="최신 개발 버전 APK 가 나왔어요!🎉
[배포 버전] : $VERSION!
[해당 PR 제목] : $PR_TITLE"
EMBED=$(jq -n \
--arg title "PR Merged: $PR_TITLE" \
--arg url "$PR_URL" \
--arg description "Version: $VERSION 🎉" \
'{
"title": $title,
"url": $url,
"description": $description,
"color": 3066993
}'
)
PAYLOAD=$(jq -n \
--arg content "$CONTENT" \
--argjson embeds "[$EMBED]" \
'{
"content": $content,
"embeds": $embeds
}'
)
curl -F "payload_json=$PAYLOAD" \
-F "file=@app/build/outputs/apk/alpha/app-alpha.apk" \
$DISCORD_WEBHOOK_URL