-
Notifications
You must be signed in to change notification settings - Fork 25
97 lines (86 loc) · 2.92 KB
/
npm-android-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
name: Android Build via Gradlew
on:
workflow_call:
inputs:
SERVICE_LOCATION:
description: 'SERVICE LOCATION'
required: true
type: string
ANDROID_LOCATION:
description: 'ANDROID LOCATION'
required: false
type: string
default: false
BUILD_ARTIFACT:
description: 'SERVICE NAME'
required: true
type: string
GRADLEW_ARGS:
description: 'Provide gradlew arguments'
required: false
type: string
secrets:
SLACK_WEBHOOK_URL:
required: true
env:
ANDROID_HOME: '/opt/android-sdk/'
jobs:
npm-andriod-build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: actions/[email protected]
with:
node-version: '16'
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: '~/.npm'
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: NPM Install Dependencies
run: cd ${{ inputs.SERVICE_LOCATION }} && npm install
- name: Build APK via Gradlew
if: ${{ inputs.ANDROID_LOCATION != 'false' }}
run: |
cd ${{ inputs.SERVICE_LOCATION }}/${{ inputs.ANDROID_LOCATION }}
sed -i -e 's/\r$//' ./gradlew
chmod +x ./gradlew
./gradlew ${{ inputs.GRADLEW_ARGS }}
- name: Verify the build application
run: cd ${{ inputs.SERVICE_LOCATION }} && npm run verify
- name: Find *.apk files
id: apk
run: |
echo "FOUND_APK=false" >> $GITHUB_OUTPUT
APK_LIST=$( find -name '*.apk' )
if [[ $APK_LIST != '' ]]; then
echo "FOUND_APK=true" >> $GITHUB_OUTPUT
fi
find -name '*.apk' -type f -exec zip ${{ inputs.BUILD_ARTIFACT }}.zip {} +
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.BUILD_ARTIFACT }}
path: ${{ inputs.BUILD_ARTIFACT }}.zip
retention-days: 5
if: (steps.apk.outputs.FOUND_APK == 'true')
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,author,commit,workflow,job # selectable (default: repo,message)
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: "${{ github.event_name != 'pull_request' && failure() }}" # Pick up events even if the job fails or is canceled.