From 6da9f5f20e3c7db8b1c95eccb48f68c8a7e883f1 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 10 Jun 2026 17:27:58 -0500 Subject: [PATCH] Add placeholder comment for web flasher during PR builds --- .../workflows/flasher-link-placeholder.yml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/flasher-link-placeholder.yml diff --git a/.github/workflows/flasher-link-placeholder.yml b/.github/workflows/flasher-link-placeholder.yml new file mode 100644 index 000000000..88e66db86 --- /dev/null +++ b/.github/workflows/flasher-link-placeholder.yml @@ -0,0 +1,60 @@ +name: Post Web Flasher Build Placeholder + +# Drops an immediate "build in progress" comment when a PR opens, so the web +# flasher entry shows up right away. The real CI-driven workflow +# (flasher-link-comment.yml) later replaces it in place via the shared marker. +# +# SECURITY: this uses pull_request_target (write token, runs for fork PRs) but is +# safe because it never checks out or runs PR code and posts a fully static body +# — no PR title, branch name, or other untrusted input is used anywhere. + +on: + pull_request_target: + types: [opened, reopened] + +permissions: + pull-requests: write + +jobs: + post-placeholder: + if: github.repository == 'meshtastic/firmware' + continue-on-error: true + runs-on: ubuntu-latest + steps: + - name: Post web flasher build-in-progress placeholder + uses: actions/github-script@v8 + with: + script: | + const marker = ''; + const { owner, repo } = context.repo; + const pr = context.payload.pull_request; + + // Only org members get the flasher comment (matches the real workflow) + const allowedAssociations = ['OWNER', 'MEMBER']; + if (!allowedAssociations.includes(pr.author_association)) { + core.info(`Author association ${pr.author_association} is not an org member; skipping.`); + return; + } + + // Only seed a placeholder when no flasher comment exists yet — never + // overwrite a real (or existing placeholder) comment. + const comments = await github.paginate(github.rest.issues.listComments, { + owner, repo, issue_number: pr.number, per_page: 100, + }); + if (comments.some((c) => c.body?.includes(marker))) { + core.info('Flasher comment already exists; nothing to do.'); + return; + } + + const body = [ + marker, + '## ⚡ Try this PR in the Web Flasher', + '', + '> [!NOTE]', + '> Building this pull request… the flash button, badges and supported-board', + '> list will appear here automatically once CI finishes.', + ].join('\n'); + + await github.rest.issues.createComment({ + owner, repo, issue_number: pr.number, body, + });