From cb95ddbd04161633faf4d5e816efc2a827f5470e Mon Sep 17 00:00:00 2001 From: Arthur Tazhitdinov Date: Fri, 30 Jan 2026 22:24:51 +0500 Subject: [PATCH] feat: enhance PR commenting with firmware stats and upload firmware artifact --- .github/workflows/ci.yml | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 344bc945..514bc98c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 = ''; 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,