mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-04-21 08:14:42 +01:00
feat: Build in pr (#1101)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
75
.github/workflows/artifact-comment.yml
vendored
75
.github/workflows/artifact-comment.yml
vendored
@@ -1,23 +1,21 @@
|
|||||||
name: 📝 Artifact Comment on PR
|
name: 📝 Artifact Comment on PR
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: artifact-comment-${{ github.event.workflow_run.id }}
|
group: artifact-comment-${{ github.event.workflow_run.id || github.run_id }}
|
||||||
cancel-in-progress: false
|
cancel-in-progress: false
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch: # Allow manual testing
|
||||||
workflow_run:
|
workflow_run:
|
||||||
workflows:
|
workflows:
|
||||||
- "🏗️ Build iOS IPA (phone)"
|
- "🤖 Android APK Build (Phone + TV)"
|
||||||
- "🏗️ Build iOS IPA (tv)"
|
- "🤖 iOS IPA Build (Phone + TV)"
|
||||||
- "🏗️ Build Android APK (phone)"
|
|
||||||
- "🏗️ Build Android APK (tv)"
|
|
||||||
types:
|
types:
|
||||||
- completed
|
- completed
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
comment-artifacts:
|
comment-artifacts:
|
||||||
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
|
if: github.event_name == 'workflow_dispatch' || (github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -29,23 +27,56 @@ jobs:
|
|||||||
uses: actions/github-script@v8
|
uses: actions/github-script@v8
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
console.log('Workflow run event:', JSON.stringify(github.event.workflow_run, null, 2));
|
// Handle both workflow_run and manual dispatch events
|
||||||
|
let runId, pr;
|
||||||
|
|
||||||
// Find PR associated with this commit
|
if (context.eventName === 'workflow_run') {
|
||||||
const { data: pullRequests } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
|
runId = github.event.workflow_run.id;
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo,
|
// Find PR associated with this commit
|
||||||
commit_sha: "${{ github.event.workflow_run.head_sha }}"
|
const { data: pullRequests } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
|
||||||
});
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
if (pullRequests.length === 0) {
|
commit_sha: github.event.workflow_run.head_sha
|
||||||
console.log('No pull request found for commit: ${{ github.event.workflow_run.head_sha }}');
|
});
|
||||||
|
|
||||||
|
if (pullRequests.length === 0) {
|
||||||
|
console.log('No pull request found for commit:', github.event.workflow_run.head_sha);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pr = pullRequests[0];
|
||||||
|
|
||||||
|
} else if (context.eventName === 'workflow_dispatch') {
|
||||||
|
// For manual testing, use most recent test workflow run
|
||||||
|
const { data: workflows } = await github.rest.actions.listWorkflowRuns({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
workflow_id: 'test-artifact.yml',
|
||||||
|
per_page: 1
|
||||||
|
});
|
||||||
|
|
||||||
|
if (workflows.workflow_runs.length === 0) {
|
||||||
|
console.log('No test workflow runs found');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const testRun = workflows.workflow_runs[0];
|
||||||
|
runId = testRun.id;
|
||||||
|
|
||||||
|
// Get current PR for manual testing
|
||||||
|
const prNumber = context.payload.pull_request?.number || 1101;
|
||||||
|
const { data: prData } = await github.rest.pulls.get({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
pull_number: prNumber
|
||||||
|
});
|
||||||
|
pr = prData;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log('Unsupported event type:', context.eventName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pr = pullRequests[0];
|
|
||||||
const runId = "${{ github.event.workflow_run.id }}";
|
|
||||||
|
|
||||||
console.log(`Found PR #${pr.number} for commit ${pr.head.sha.substring(0, 7)}`);
|
console.log(`Found PR #${pr.number} for commit ${pr.head.sha.substring(0, 7)}`);
|
||||||
|
|
||||||
// Get artifacts from the workflow run
|
// Get artifacts from the workflow run
|
||||||
@@ -55,8 +86,6 @@ jobs:
|
|||||||
run_id: runId
|
run_id: runId
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(`Found ${artifacts?.artifacts?.length || 0} artifacts`);
|
|
||||||
|
|
||||||
if (!artifacts || artifacts.artifacts.length === 0) {
|
if (!artifacts || artifacts.artifacts.length === 0) {
|
||||||
console.log('No artifacts found for this run');
|
console.log('No artifacts found for this run');
|
||||||
return;
|
return;
|
||||||
@@ -70,8 +99,6 @@ jobs:
|
|||||||
.filter(a => a.name.includes('ios'))
|
.filter(a => a.name.includes('ios'))
|
||||||
.sort((a, b) => a.name.localeCompare(b.name));
|
.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
|
|
||||||
console.log(`Android artifacts: ${androidArtifacts.length}, iOS artifacts: ${iosArtifacts.length}`);
|
|
||||||
|
|
||||||
// Build comment body with table format
|
// Build comment body with table format
|
||||||
let commentBody = `## 📱 Build Artifacts Ready!\n\n`;
|
let commentBody = `## 📱 Build Artifacts Ready!\n\n`;
|
||||||
commentBody += `✅ **Workflow completed successfully** for PR #${pr.number}\n`;
|
commentBody += `✅ **Workflow completed successfully** for PR #${pr.number}\n`;
|
||||||
|
|||||||
Reference in New Issue
Block a user