feat: enhance PR commenting with firmware stats and upload firmware artifact

This commit is contained in:
Arthur Tazhitdinov 2026-01-30 22:24:51 +05:00
parent 826ccb2d25
commit cb95ddbd04

View File

@ -86,7 +86,14 @@ jobs:
if [ -n "$flash_line" ]; then echo "- ${flash_line}"; else echo "- Flash: not found"; fi
} >> "$GITHUB_STEP_SUMMARY"
- name: Comment PR with firmware stats
- name: Upload firmware.bin artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.event_name == 'pull_request' && format('firmware-bin-pr-{0}-{1}', github.event.pull_request.number, github.sha) || format('firmware-bin-{0}', github.sha) }}
path: .pio/build/default/firmware.bin
if-no-files-found: error
- name: Comment PR with firmware stats and firmware.bin
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
@ -94,7 +101,27 @@ jobs:
const marker = '<!-- firmware-stats -->';
const ram = `${{ steps.fw_stats.outputs.ram_line }}`.trim();
const flash = `${{ steps.fw_stats.outputs.flash_line }}`.trim();
const body = `${marker}\n**Firmware build stats**\n\n\`\`\`\n${ram || 'RAM: not found'}\n${flash || 'Flash: not found'}\n\`\`\``;
const prNumber = context.payload.pull_request?.number;
const artifactName = prNumber
? `firmware-bin-pr-${prNumber}-${context.sha}`
: `firmware-bin-${context.sha}`;
let firmwareLine = 'Firmware: artifact not found';
try {
const { data: artifacts } = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.runId,
});
const firmwareArtifact = artifacts.artifacts.find((artifact) => artifact.name === artifactName);
if (firmwareArtifact) {
firmwareLine = `Firmware: [firmware.bin artifact](${firmwareArtifact.archive_download_url})`;
} else {
firmwareLine = `Firmware: artifact not found (${artifactName})`;
}
} catch (error) {
firmwareLine = `Firmware: artifact lookup failed (${error.message})`;
}
const body = `${marker}\n**Firmware build stats**\n\n\`\`\`\n${ram || 'RAM: not found'}\n${flash || 'Flash: not found'}\n\`\`\`\n\n**Firmware binary**\n${firmwareLine}`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,