Update Build Cache #73
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Build Cache | |
on: | |
schedule: | |
- cron: "37 13 * * SAT" | |
workflow_dispatch: | |
jobs: | |
update-cache: | |
timeout-minutes: 30 | |
runs-on: ubuntu-latest | |
env: | |
androidApiVersion: 31 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: '17' | |
- name: Detect gradle version | |
uses: actions/github-script@v6 | |
id: gradle-version-detector | |
with: | |
result-encoding: string | |
script: | | |
const scriptPath = '/./.github/scripts/gradle-version-detector.js' | |
const script = require(`${process.env.GITHUB_WORKSPACE}${scriptPath}`) | |
return script() | |
- name: Fetch gradle cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-${{ steps.gradle-version-detector.outputs.result }} | |
- name: Copy CI gradle.properties | |
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties | |
- name: Make gradlew executable | |
run: chmod +x ./gradlew | |
- name: Fetch AVD Cache | |
uses: actions/cache@v3 | |
id: avd-cache | |
with: | |
path: | | |
~/.android/avd/* | |
~/.android/adb* | |
key: ${{ runner.os }}-avd-${{ env.androidApiVersion }} | |
- name: Create AVD and generate snapshot for caching | |
if: steps.avd-cache.outputs.cache-hit != 'true' | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: ${{ env.androidApiVersion }} | |
target: aosp_atd | |
channel: stable | |
arch: x86_64 | |
ram-size: 3072M | |
disk-size: 2048M | |
force-avd-creation: false | |
disable-animations: true | |
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none | |
script: echo "Generated AVD snapshot for caching." | |
- name: 🚧 Build and Update Cache | |
run: ./gradlew assembleDebug | |
- name: 💌 Send email report | |
uses: actions/github-script@v6 | |
env: | |
MAIL_USERNAME: ${{ secrets.MAIL_USERNAME }} | |
MAIL_PASSWORD: ${{ secrets.MAIL_PASSWORD }} | |
with: | |
script: | | |
const subject = `Github Actions cache status of Jetflix ¯\\_(ツ)_/¯` | |
const reportGeneratorScriptPath = '/./.github/scripts/cache-update-report-generator.js' | |
const reportGeneratorScript = require(`${process.env.GITHUB_WORKSPACE}${reportGeneratorScriptPath}`) | |
const report = await reportGeneratorScript({github, context}) | |
const mailSenderScriptPath = '/./.github/scripts/report-mail-sender.js' | |
const mailSenderScript = require(`${process.env.GITHUB_WORKSPACE}${mailSenderScriptPath}`) | |
mailSenderScript(subject, report) |