-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (107 loc) · 3.83 KB
/
Android_Develop_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
name: Android PR Builder
on:
pull_request:
types:
- closed
branches: [ an/develop ]
defaults:
run:
working-directory: ./android
jobs:
CI_Android_Develop:
uses: ./.github/workflows/Android_Develop_CI.yml
secrets: inherit
Distribution_To_Discord:
name: Alpha APK to Discord
runs-on: ubuntu-latest
needs: [ CI_Android_Develop ]
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 }}
run: |
echo POKE_BASE_URL=\"${{ secrets.POKE_BASE_URL }}\" >> local.properties
- 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