mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-02-19 02:22:23 +00:00
Replaces the workflow_run trigger mechanism with repository_dispatch events to enable real-time build status communication between build workflows and the artifact comment system. Build workflows now actively notify the comment workflow when builds start, complete, or fail, providing immediate status updates rather than polling for completed workflows. Adds real-time payload processing to display current build status and target information in PR comments, improving visibility into ongoing build processes. BREAKING CHANGE: Changes the trigger mechanism from workflow_run to repository_dispatch, requiring build workflows to explicitly send status notifications.
155 lines
5.6 KiB
YAML
155 lines
5.6 KiB
YAML
name: 🤖 Android APK Build (Phone + TV)
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
branches: [develop, master]
|
|
push:
|
|
branches: [develop, master]
|
|
|
|
jobs:
|
|
build-android:
|
|
if: (!contains(github.event.head_commit.message, '[skip ci]'))
|
|
runs-on: ubuntu-24.04
|
|
name: 🏗️ Build Android APK
|
|
permissions:
|
|
contents: read
|
|
repository-projects: write
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
target: [phone, tv]
|
|
|
|
steps:
|
|
- name: 📢 Notify artifact comment workflow (started)
|
|
if: github.event_name == 'pull_request'
|
|
uses: actions/github-script@v8
|
|
with:
|
|
script: |
|
|
await github.rest.repos.createDispatchEvent({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
event_type: 'build-started',
|
|
client_payload: {
|
|
workflow_name: 'Android APK Build',
|
|
target: '${{ matrix.target }}',
|
|
status: 'in_progress',
|
|
pr_number: ${{ github.event.pull_request.number }},
|
|
commit_sha: '${{ github.event.pull_request.head.sha }}',
|
|
run_id: ${{ github.run_id }},
|
|
run_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
|
|
}
|
|
});
|
|
|
|
- name: 📥 Checkout code
|
|
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
|
fetch-depth: 0
|
|
submodules: recursive
|
|
show-progress: false
|
|
|
|
- name: 🍞 Setup Bun
|
|
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
|
|
with:
|
|
bun-version: latest
|
|
|
|
- name: 💾 Cache Bun dependencies
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
with:
|
|
path: ~/.bun/install/cache
|
|
key: ${{ runner.os }}-${{ runner.arch }}-bun-develop-${{ hashFiles('bun.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-${{ runner.arch }}-bun-develop
|
|
${{ runner.os }}-bun-develop
|
|
|
|
- name: 📦 Install dependencies and reload submodules
|
|
run: |
|
|
bun install --frozen-lockfile
|
|
bun run submodule-reload
|
|
|
|
- name: 💾 Cache Gradle global
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: ${{ runner.os }}-gradle-develop-${{ hashFiles('android/**/build.gradle', 'android/gradle/wrapper/gradle-wrapper.properties') }}
|
|
restore-keys: ${{ runner.os }}-gradle-develop
|
|
|
|
- name: 🛠️ Generate project files
|
|
run: |
|
|
if [ "${{ matrix.target }}" = "tv" ]; then
|
|
bun run prebuild:tv
|
|
else
|
|
bun run prebuild
|
|
fi
|
|
|
|
- name: 💾 Cache project Gradle (.gradle)
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
|
with:
|
|
path: android/.gradle
|
|
key: ${{ runner.os }}-android-gradle-develop-${{ hashFiles('android/**/build.gradle', 'android/gradle/wrapper/gradle-wrapper.properties') }}
|
|
restore-keys: ${{ runner.os }}-android-gradle-develop
|
|
|
|
- name: 🚀 Build APK
|
|
env:
|
|
EXPO_TV: ${{ matrix.target == 'tv' && 1 || 0 }}
|
|
run: bun run build:android:local
|
|
|
|
- name: 📅 Set date tag
|
|
run: echo "DATE_TAG=$(date +%d-%m-%Y_%H-%M-%S)" >> $GITHUB_ENV
|
|
|
|
- name: 📤 Upload APK artifact
|
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
with:
|
|
name: streamyfin-android-${{ matrix.target }}-apk-${{ env.DATE_TAG }}
|
|
path: |
|
|
android/app/build/outputs/apk/release/*.apk
|
|
retention-days: 7
|
|
|
|
- name: 🔔 Notify artifact comment workflow (success)
|
|
if: success() && github.event_name == 'pull_request'
|
|
uses: actions/github-script@v8
|
|
with:
|
|
script: |
|
|
await github.rest.repos.createDispatchEvent({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
event_type: 'build-completed',
|
|
client_payload: {
|
|
workflow_name: 'Android APK Build',
|
|
target: '${{ matrix.target }}',
|
|
status: 'success',
|
|
pr_number: ${{ github.event.pull_request.number }},
|
|
commit_sha: '${{ github.event.pull_request.head.sha }}',
|
|
run_id: ${{ github.run_id }},
|
|
run_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
|
|
}
|
|
});
|
|
|
|
- name: 🔔 Notify artifact comment workflow (failure)
|
|
if: failure() && github.event_name == 'pull_request'
|
|
uses: actions/github-script@v8
|
|
with:
|
|
script: |
|
|
await github.rest.repos.createDispatchEvent({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
event_type: 'build-failed',
|
|
client_payload: {
|
|
workflow_name: 'Android APK Build',
|
|
target: '${{ matrix.target }}',
|
|
status: 'failure',
|
|
pr_number: ${{ github.event.pull_request.number }},
|
|
commit_sha: '${{ github.event.pull_request.head.sha }}',
|
|
run_id: ${{ github.run_id }},
|
|
run_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
|
|
}
|
|
});
|