feat!: replace workflow_run with repository_dispatch for real-time build status updates

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.
This commit is contained in:
Uruk
2025-09-30 00:51:02 +02:00
parent 44e489f40c
commit 2b761f15c8
3 changed files with 207 additions and 31 deletions

View File

@@ -18,6 +18,7 @@ jobs:
name: 🏗️ Build Android APK
permissions:
contents: read
repository-projects: write
strategy:
fail-fast: false
@@ -25,6 +26,26 @@ jobs:
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:
@@ -91,3 +112,43 @@ jobs:
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 }}'
}
});