Open Source Projects
MemBrowse supports tokenless uploads for open-source projects. When the API key is not available on a pull request, such as a fork PR or a Dependabot PR where repository secrets are inaccessible, the action automatically falls back to uploading without authentication. MemBrowse recognizes that the upload originates from a GitHub Actions context and matches it to the correct project. Tokenless uploads only work for projects marked as open source in the MemBrowse Portal. The report still reaches the MemBrowse Portal with full analysis.
Pushes always need an API key. Tokenless uploads apply to pull requests only.
The standard single-workflow setup from Setup works for:
- Private repositories
- Public repositories where PRs come from branches within the same repo
If your project accepts PRs from external contributors (forks), or you want comments on Dependabot PRs, use the two-workflow setup below. The split is needed because these PRs cannot read secrets or write PR comments — the upload itself works fine without secrets.
How It Works
- Report workflow — triggers on PRs and pushes, builds the firmware, analyzes memory, and uploads the report. On fork PRs the API key secret is empty, so the action uses tokenless upload.
- Comment workflow — triggers via
workflow_runwhen the report workflow completes. It runs in the context of the base repository, where the API key and write permissions are available, fetches the summary from the MemBrowse API, and posts the PR comment.
Report Workflow
Create .github/workflows/membrowse-report.yml:
name: MemBrowse Memory Report
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
analyze:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 2
# Add your build tool setup here
- name: Build firmware
run: make all
# continue-on-error ensures the workflow doesn't fail if memory
# analysis has an issue — keeps MemBrowse non-blocking.
- name: Analyze memory
continue-on-error: true
uses: membrowse/membrowse-action@v1
with:
elf: build/firmware.elf
ld: linker.ld
target_name: my-target
api_key: ${{ secrets.MEMBROWSE_API_KEY }}
# linker_vars: "__flash_size__=512K" # Optional: linker variable definitions
The api_key is passed as ${{ secrets.MEMBROWSE_API_KEY }}. On pushes to main and same-repo PRs, this authenticates normally. On fork PRs, the secret is empty and the action falls back to tokenless upload — the report still reaches the portal.
Multiple targets
If you use membrowse-targets.json, make these changes to the report workflow:
- Add the
setupjob that readsmembrowse-targets.json(see Multiple Targets) - Replace the single
analyzejob with the matrixanalyzepattern
The comment workflow needs no changes. The summary for a commit includes every target uploaded for it, so all targets appear in one comment.
Comment Workflow
Create .github/workflows/membrowse-comment.yml:
name: MemBrowse PR Comment
on:
workflow_run:
workflows: [MemBrowse Memory Report]
types: [completed]
permissions:
contents: read
pull-requests: write
jobs:
comment:
runs-on: ubuntu-latest
# Run even if some builds failed, but not for cancelled or skipped runs,
# where nothing was uploaded and the summary lookup would fail.
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion != 'cancelled' &&
github.event.workflow_run.conclusion != 'skipped'
steps:
- name: Post PR comment
uses: membrowse/membrowse-action/comment-action@v1
with:
api_key: ${{ secrets.MEMBROWSE_API_KEY }}
commit: ${{ github.event.workflow_run.head_sha }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
This workflow has access to your secrets and can write to PRs. Never check out or build the PR's code here. If you use a comment_template, check out the default branch (the actions/checkout default for workflow_run), so the template can't be changed from a fork.
Action Reference
For all comment-action inputs, see the Action Reference.
PR Number Resolution
The comment-action needs to know which PR to post the comment on. It resolves the PR number automatically in this order:
- Explicit
pr_numberinput — if you pass it directly - GitHub event context — from
github.event.pull_request.number(directpull_requesttrigger) - MemBrowse API — the
/summaryresponse includes thepr_numberfrom the upload metadata
For most setups, including fork PRs, step 3 handles it automatically — the PR number is captured during the report upload and returned by the API. No extra configuration is needed. If none of these gives a PR number, the action logs a warning and skips the comment.
Troubleshooting
PR comments not appearing
- Verify the
workflow_runtrigger references the exact workflow name:MemBrowse Memory Report - Check that
GITHUB_TOKENhaspull-requests: writepermission - Check that the
MEMBROWSE_API_KEYsecret is set in the base repository - Check the comment workflow logs in the Actions tab — it runs as a separate workflow, so look for "MemBrowse PR Comment" runs
Report workflow succeeds but comment workflow doesn't trigger
GitHub only runs workflow_run workflows from the version on your default branch, so the comment workflow must be merged there first. It also skips report runs that were cancelled or skipped, or that weren't triggered by a pull_request event. Check the if condition in the comment job.