Skip to content

CANVAS support via AFC #281

CANVAS support via AFC

CANVAS support via AFC #281

Workflow file for this run

name: Build OpenCentauri Image (on PR)
on:
pull_request:
permissions:
contents: read
pull-requests: write
actions: read
jobs:
select-approval-environment:
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.select.outputs.environment }}
steps:
- name: Select approval environment
id: select
uses: actions/github-script@v7
env:
AUTO_APPROVE: ${{ vars.AUTO_APPROVE }}
with:
script: |
const username = context.payload.pull_request.user.login;
const autoApproveUsers = (process.env.AUTO_APPROVE || '')
.split(',')
.map((value) => value.trim().toLowerCase())
.filter(Boolean);
const environment = autoApproveUsers.includes(username.toLowerCase())
? 'approval-given'
: 'approval-needed';
core.info(`Selected ${environment} for ${username}.`);
core.setOutput('environment', environment);
approve:
needs: select-approval-environment
runs-on: ubuntu-latest
environment: ${{ needs.select-approval-environment.outputs.environment }}
steps:
- run: echo "Using environment ${{ needs.select-approval-environment.outputs.environment }}"
build:
needs: approve
uses: ./.github/workflows/build.yml
with:
use_cache: true
write_back_cache: false
upload_all_artifacts: false
version: PR-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}
comment:
needs: build
if: always() && needs.build.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Get workflow run info
id: run_info
uses: actions/github-script@v7
with:
script: |
const headSha = context.payload.pull_request.head.sha.substring(0, 7);
const branch = context.payload.pull_request.head.ref;
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
});
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
let artifactRows = '';
for (const artifact of artifacts.data.artifacts) {
const sizeMB = (artifact.size_in_bytes / (1024 * 1024)).toFixed(2);
const artifactUrl = `${runUrl}/artifacts/${artifact.id}`;
artifactRows += `| [${artifact.name}](${artifactUrl}) | ${sizeMB} MB |\n`;
}
if (!artifactRows) {
artifactRows = '| _No artifacts uploaded_ | - |\n';
}
const body = `## ✅ Build Artifacts\n\n` +
`**Branch:** \`${branch}\`\n` +
`**Build:** \`${headSha}\` (merge into \`${context.payload.pull_request.base.ref}\`)\n\n` +
`| Artifact | Size |\n` +
`| --- | --- |\n` +
artifactRows + `\n` +
`[View workflow run](${runUrl})`;
core.setOutput('body', body);
- name: Post PR comment
uses: peter-evans/create-or-update-comment@v4
continue-on-error: true
with:
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.run_info.outputs.body }}