Skip to content

Commit 7c1098d

Browse files
committed
ci: post sticky PR comment with fallow audit findings
Reviewers shouldn't have to dig through CI logs to see what fallow flagged. With this change, on every PR the fallow job posts (or updates) a sticky comment containing the full audit report formatted as a collapsible markdown table. The comment uses fallow's built-in `pr-comment-github` format, which already emits a `<!-- fallow-id: fallow-results -->` sentinel. `marocchino/sticky-pull-request-comment@v2.9.1` matches that header so each run replaces the previous comment instead of stacking new ones. The job now runs in three steps: 1. Run `fallow audit ... --format pr-comment-github` with `continue-on-error: true` so the comment posts even when the audit fails. Exit code is captured. 2. Post (or update) the sticky comment with the captured output. 3. Re-emit the audit exit code so the job still fails-the-build on new findings. Bumps the workflow's `pull-requests` permission from read to write, needed for the sticky-comment poster to call the issues API.
1 parent 0c088b7 commit 7c1098d

1 file changed

Lines changed: 53 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,24 +86,74 @@ jobs:
8686
# the changed files. The default `--gate new-only` means existing legacy
8787
# findings don't fail the build — only NEW issues introduced by the PR do.
8888
# This stops bleeding while letting incremental cleanup land separately.
89+
#
90+
# On findings, the job posts (or updates) a sticky comment on the PR so
91+
# reviewers see the full list inline instead of digging through CI logs.
8992
fallow:
9093
name: Fallow audit
9194
needs: changes
9295
if: needs.changes.outputs.code == 'true' && github.event_name == 'pull_request'
9396
runs-on: ubuntu-latest
9497
timeout-minutes: 5
98+
# Scope write access to this single job — the rest of `ci.yml` keeps the
99+
# workflow-level `pull-requests: read` default so build / lint / test
100+
# tokens can't post or modify PR comments. Job-level permissions override
101+
# the workflow block.
102+
permissions:
103+
contents: read
104+
pull-requests: write
95105
steps:
96106
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
97107
with:
98108
# Full history so `--base origin/main` can diff against the merge
99109
# base on stacked PRs, not just the shallow tip.
100110
fetch-depth: 0
111+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
101112
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
102113
with:
103114
node-version: 22
104-
# Pinned version — bumps land via a deliberate PR. Keep in sync with
105-
# the version that produced the current `.fallowrc.jsonc` config.
106-
- run: npx -y fallow@2.75.0 audit --base origin/main --fail-on-issues
115+
- run: bun install --frozen-lockfile
116+
- name: Run fallow audit
117+
id: audit
118+
# `bun install` above made `bunx fallow` resolve from node_modules, so
119+
# we don't re-download fallow each run. The script disables `errexit`
120+
# so the audit's non-zero exit (on findings) doesn't abort before we
121+
# write the exit code to the step output. The size check guards
122+
# against fallow crashing before producing markdown (e.g. transient
123+
# parse failure) — without it we'd post a blank sticky comment.
124+
run: |
125+
set +e
126+
bunx fallow audit --base origin/main --fail-on-issues \
127+
--format pr-comment-github \
128+
> /tmp/fallow-comment.md
129+
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
130+
if [ ! -s /tmp/fallow-comment.md ]; then
131+
echo "fallow produced no output — see the job logs above." > /tmp/fallow-comment.md
132+
fi
133+
- name: Post sticky comment (findings)
134+
if: steps.audit.outputs.exit_code != '0'
135+
# Fork PRs run with a read-only GITHUB_TOKEN regardless of the
136+
# workflow's `permissions:` block, so the comment post will fail on
137+
# forks. Don't fail the whole job — the audit gate below still fires.
138+
continue-on-error: true
139+
uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.1
140+
with:
141+
# `header` matches fallow's built-in `<!-- fallow-id: fallow-results -->`
142+
# sentinel so subsequent runs update the same comment.
143+
header: fallow-results
144+
path: /tmp/fallow-comment.md
145+
- name: Remove stale sticky comment (clean run)
146+
if: steps.audit.outputs.exit_code == '0'
147+
continue-on-error: true
148+
uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.1
149+
with:
150+
header: fallow-results
151+
delete: true
152+
- name: Fail if audit found issues
153+
if: steps.audit.outputs.exit_code != '0'
154+
run: |
155+
echo "::error::Fallow audit found new issues — see the PR comment above for details."
156+
exit 1
107157
108158
format:
109159
name: Format

0 commit comments

Comments
 (0)