-
Notifications
You must be signed in to change notification settings - Fork 7
114 lines (102 loc) · 3.93 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
109
110
111
112
113
114
# Build
name: Build
on:
pull_request:
branches: [main]
pull_request_target:
branches: [main]
push:
branches: [main]
tags:
- '*'
jobs:
test:
runs-on: ubuntu-latest
# If the PR is coming from a fork (pull_request_target), ensure it's opened by "dependabot[bot]".
# Otherwise, clone it normally.
# This allows Dependabot PRs to have access to the repository Secrets,
# but using the Workflows in the context of the base branch
if: |
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
- name: Prerequisites
env:
APP_GOOGLE_SERVICES_JSON: ${{ secrets.APP_GOOGLE_SERVICES_JSON }}
TASKER_PLUGIN_GOOGLE_SERVICES_JSON: ${{ secrets.TASKER_PLUGIN_GOOGLE_SERVICES_JSON }}
run: |
echo "${APP_GOOGLE_SERVICES_JSON}" > app/google-services.json
echo "${TASKER_PLUGIN_GOOGLE_SERVICES_JSON}" > tasker-plugin/google-services.json
- name: Unit Tests
uses: gradle/gradle-build-action@v2
with:
# Only write to the cache for builds on the 'main' branch.
# Builds on other branches will only read existing entries from the cache.
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
arguments: testDevDebugUnitTest
reports:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
- name: Unit Tests
uses: gradle/gradle-build-action@v2
with:
# Only write to the cache for builds on the 'main' branch.
# Builds on other branches will only read existing entries from the cache.
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
arguments: htmlDependencyReport
assemble:
strategy:
fail-fast: false
matrix:
app: [ app, tasker-plugin ]
runs-on: ubuntu-latest
# If the PR is coming from a fork (pull_request_target), ensure it's opened by "dependabot[bot]".
# Otherwise, clone it normally.
# This allows Dependabot PRs to have access to the repository Secrets,
# but using the Workflows in the context of the base branch
if: |
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: '11'
- name: Prerequisites
env:
APP_GOOGLE_SERVICES_JSON: ${{ secrets.APP_GOOGLE_SERVICES_JSON }}
TASKER_PLUGIN_GOOGLE_SERVICES_JSON: ${{ secrets.TASKER_PLUGIN_GOOGLE_SERVICES_JSON }}
run: |
if [[ "${{ matrix.app }}" == "app" ]]; then
export envVarValue="${APP_GOOGLE_SERVICES_JSON}"
elif [[ "${{ matrix.app }}" == "tasker-plugin" ]]; then
export envVarValue="${TASKER_PLUGIN_GOOGLE_SERVICES_JSON}"
else
echo "Unsupported value for 'matrix.app': ${{ matrix.app }}"
exit 1
fi
echo "${envVarValue}" > ${{ matrix.app }}/google-services.json
- name: Assemble ${{ matrix.app }}
uses: gradle/gradle-build-action@v2
with:
# Only write to the cache for builds on the 'main' branch.
# Builds on other branches will only read existing entries from the cache.
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
arguments: :${{ matrix.app }}:assembleDevDebug