-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (91 loc) · 2.72 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
name: Android CI
on:
push:
branches:
- main
- develop
pull_request:
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
security-events: write
steps:
# 1. Checkout code
- name: Checkout code
uses: actions/checkout@v4
# 1.1 Setup google-services.json
- name: Setup google-services.json
run: |
echo "Setting up google-services.json..."
echo '${{ secrets.GOOGLE_SERVICES_JSON }}' > ./app/google-services.json
if [ -f ./app/google-services.json ]; then
echo "google-services.json successfully created at ./app/google-services.json"
else
echo "Error: google-services.json not found at ./app/google-services.json"
exit 1
fi
shell: bash
env:
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
# 2. Set up JDK
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
# 3. Cache Gradle
- name: Cache Gradle
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-
# 4. Add Local Properties
- name: Add Local Properties
env:
BASE_URL: ${{ secrets.BASE_URL }}
run: |
echo base.url=\"$BASE_URL\" >> ./local.properties
# 5. Run Static Analysis (Detekt)
- name: Run Detekt
run: ./gradlew detekt
# 6. Check Code Formatting (Spotless)
- name: Run Spotless Check
run: ./gradlew spotlessCheck
# # 6. Run Unit Tests
# - name: Run Unit Tests
# run: ./gradlew test
# 7. Run Lint
- name: Run Lint
run: ./gradlew lint
# 8. Build APK
- name: Build APK
run: ./gradlew assembleDebug
# 9. Upload Artifacts
- name: Upload APKs
uses: actions/upload-artifact@v4
with:
name: APKs
path: '**/build/outputs/apk/**/*.apk'
- name: Upload Test Results
uses: actions/upload-artifact@v4
with:
name: Test Results
path: '**/build/test-results/**/*.xml'
# 10. Notify in Slack
- name: Notify in Slack
uses: 8398a7/action-slack@v3
with:
status: ${{job.status}}
fields: repo,message,commit,author,action,eventName,ref,workflow
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()