2024-03-03 18:50:44 +01:00
|
|
|
name: "Build and sign APK for PR"
|
|
|
|
|
|
|
|
# Based on https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
|
|
|
|
on:
|
|
|
|
issue_comment:
|
|
|
|
types: [created]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
deploy:
|
|
|
|
name: Deploy
|
|
|
|
# Only run on PR comments containing "/apk"
|
|
|
|
if: github.event.issue.pull_request && contains(github.event.comment.body, '/apk')
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Get branch of PR
|
2024-03-21 13:10:59 +01:00
|
|
|
uses: xt0rted/pull-request-comment-branch@d97294d304604fa98a2600a6e2f916a84b596dc7 # v2
|
2024-03-03 18:50:44 +01:00
|
|
|
id: comment-branch
|
|
|
|
|
|
|
|
- name: Set latest commit status as pending
|
2024-03-21 13:10:59 +01:00
|
|
|
uses: myrotvorets/set-commit-status-action@3730c0a348a2ace3c110851bed53331bc6406e9f # v2.0.1
|
2024-03-03 18:50:44 +01:00
|
|
|
with:
|
|
|
|
sha: ${{ steps.comment-branch.outputs.head_sha }}
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
status: pending
|
|
|
|
|
|
|
|
- name: Checkout PR branch ${{ steps.comment-branch.outputs.head_ref }}
|
2024-03-21 13:10:59 +01:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
|
2024-03-03 18:50:44 +01:00
|
|
|
with:
|
|
|
|
ref: ${{ steps.comment-branch.outputs.head_ref }}
|
|
|
|
|
2024-03-21 13:10:59 +01:00
|
|
|
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4
|
2024-03-03 18:50:44 +01:00
|
|
|
with:
|
|
|
|
java-version: '17'
|
|
|
|
distribution: 'temurin'
|
|
|
|
|
|
|
|
- name: Gradle Wrapper Validation
|
2024-03-22 08:48:27 +01:00
|
|
|
uses: gradle/wrapper-validation-action@b231772637bb498f11fdbc86052b6e8a8dc9fc92 # v2
|
2024-03-03 18:50:44 +01:00
|
|
|
|
|
|
|
- name: Copy CI gradle.properties
|
|
|
|
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
|
|
|
|
|
|
|
|
- name: Setup Gradle
|
2024-04-09 13:00:20 +02:00
|
|
|
uses: gradle/actions/setup-gradle@1168cd3d07c1876a65e1724114de42ccbdfa7b78 # v3
|
2024-03-03 18:50:44 +01:00
|
|
|
with:
|
|
|
|
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
|
|
|
|
|
|
|
|
- name: Test
|
|
|
|
run: ./gradlew app:testOrangeGoogleReleaseUnitTest --stacktrace
|
|
|
|
|
|
|
|
- name: Build APK
|
|
|
|
run: ./gradlew assembleOrangeGoogleRelease --stacktrace
|
|
|
|
|
2024-03-21 13:10:59 +01:00
|
|
|
- uses: r0adkll/sign-android-release@dbeba6b98a60b0fd540c02443c7f428cdedf0e7f # v1.0.4
|
2024-03-03 18:50:44 +01:00
|
|
|
name: Sign app APK
|
|
|
|
id: sign_app_apk
|
|
|
|
with:
|
2024-03-03 20:01:00 +01:00
|
|
|
releaseDirectory: app/build/outputs/apk/orangeGoogle/release
|
2024-03-03 18:50:44 +01:00
|
|
|
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
|
|
|
|
alias: ${{ secrets.SIGNING_KEY_ALIAS }}
|
|
|
|
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
|
|
|
|
keyPassword: ${{ secrets.KEY_PASSWORD }}
|
|
|
|
env:
|
|
|
|
BUILD_TOOLS_VERSION: "34.0.0"
|
|
|
|
|
|
|
|
- name: Upload APK Release Asset
|
|
|
|
id: upload-release-asset-apk
|
2024-03-21 13:10:59 +01:00
|
|
|
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4
|
2024-03-03 18:50:44 +01:00
|
|
|
with:
|
|
|
|
name: app-release.apk
|
|
|
|
path: ${{steps.sign_app_apk.outputs.signedReleaseFile}}
|
|
|
|
compression-level: 0
|
|
|
|
|
|
|
|
- name: Add workflow result as comment on PR
|
2024-03-21 13:10:59 +01:00
|
|
|
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
|
2024-03-03 18:50:44 +01:00
|
|
|
if: always()
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const name = '${{ github.workflow }}';
|
|
|
|
const workflowUrl = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
|
|
|
|
const apkUrl = '${{ steps.upload-release-asset-apk.outputs.artifact-url }}'
|
|
|
|
const success = '${{ job.status }}' === 'success';
|
|
|
|
const body = `Workflow ${name}: ${success ? 'succeeded ✅' : 'failed ❌'}\nResults: ${workflowUrl}\nAPK: ${apkUrl}`;
|
|
|
|
|
|
|
|
await github.rest.issues.createComment({
|
|
|
|
issue_number: context.issue.number,
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
body: body
|
|
|
|
})
|
|
|
|
|
|
|
|
- name: Set latest commit status as ${{ job.status }}
|
2024-03-21 13:10:59 +01:00
|
|
|
uses: myrotvorets/set-commit-status-action@3730c0a348a2ace3c110851bed53331bc6406e9f # v2.0.1
|
2024-03-03 18:50:44 +01:00
|
|
|
if: always()
|
|
|
|
with:
|
|
|
|
sha: ${{ steps.comment-branch.outputs.head_sha }}
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
status: ${{ job.status }}
|