-
Notifications
You must be signed in to change notification settings - Fork 5
120 lines (102 loc) · 3.72 KB
/
Copy pathci.yml
File metadata and controls
120 lines (102 loc) · 3.72 KB
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
name: CI
on:
push:
branches: [ "master" ]
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
TERM: xterm-256color
FORCE_COLOR: 1
jobs:
build:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
outputs:
artifact-url: ${{ steps.upload-apk.outputs.artifact-url }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Setup Java
uses: actions/setup-java@v6
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Decode google-services.json
run: |
set -euo pipefail
if [ -z "${GOOGLE_SERVICES_JSON_BASE64:-}" ]; then
echo "GOOGLE_SERVICES_JSON_BASE64 is empty; using checked-in placeholder."
exit 0
fi
mkdir -p app/src/debug
printf '%s' "$GOOGLE_SERVICES_JSON_BASE64" | base64 -d > app/src/debug/google-services.json
env:
GOOGLE_SERVICES_JSON_BASE64: ${{ secrets.GOOGLE_SERVICES_JSON_BASE64 }}
- name: Build debug app
id: build
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CHATWOOT_API: ${{ secrets.CHATWOOT_API }}
run: ./gradlew assembleDevDebug
- name: Run tests
run: ./gradlew testDevDebugUnitTest
- name: Upload test report
if: always() && steps.build.outcome == 'success'
uses: actions/upload-artifact@v7
with:
name: unit_test_report_${{ github.run_number }}
path: app/build/reports/tests/testDevDebugUnitTest/
retention-days: 30
- name: Upload APK
id: upload-apk
uses: actions/upload-artifact@v7
with:
name: bitkit-dev-debug-apk_${{ github.run_number }}
path: app/build/outputs/bitkit/devDebug/bitkit-dev-debug-*-universal.apk
retention-days: 30
if-no-files-found: error
apk-comment:
needs: build
if: needs.build.outputs.artifact-url != '' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Comment APK link on PR
uses: actions/github-script@v8
env:
ARTIFACT_URL: ${{ needs.build.outputs.artifact-url }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
with:
script: |
const marker = '<!-- bitkit-dev-debug-apk -->';
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const body = [
marker,
'### Regtest APK',
'',
`Built from ${process.env.HEAD_SHA} ([run](${runUrl})).`,
'',
`[Download bitkit-dev-debug universal APK](${process.env.ARTIFACT_URL}) (expires in 30 days).`,
].join('\n');
const comments = await github.paginate(github.rest.issues.listComments, {
...context.repo,
issue_number: context.issue.number,
per_page: 100,
});
const existing = comments.find((c) => c.body?.includes(marker));
if (existing) {
await github.rest.issues.updateComment({ ...context.repo, comment_id: existing.id, body });
} else {
await github.rest.issues.createComment({ ...context.repo, issue_number: context.issue.number, body });
}