Skip to content

Commit 3d59ebb

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 3c5961a commit 3d59ebb

1 file changed

Lines changed: 42 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ name: CI
22

33
permissions:
44
contents: read
5-
pull-requests: read
5+
# NOTE: this applies to every job in this file. The only job that *needs*
6+
# write is `Fallow audit` (posts a sticky comment with findings); the rest
7+
# operate fine with read. If a future job is added that should run in an
8+
# untrusted context (e.g. on fork PRs), consider splitting `fallow` into
9+
# its own workflow with a scoped `permissions:` block.
10+
pull-requests: write
611

712
on:
813
pull_request:
@@ -86,6 +91,9 @@ jobs:
8691
# the changed files. The default `--gate new-only` means existing legacy
8792
# findings don't fail the build — only NEW issues introduced by the PR do.
8893
# This stops bleeding while letting incremental cleanup land separately.
94+
#
95+
# On findings, the job posts (or updates) a sticky comment on the PR so
96+
# reviewers see the full list inline instead of digging through CI logs.
8997
fallow:
9098
name: Fallow audit
9199
needs: changes
@@ -98,12 +106,42 @@ jobs:
98106
# Full history so `--base origin/main` can diff against the merge
99107
# base on stacked PRs, not just the shallow tip.
100108
fetch-depth: 0
109+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
101110
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
102111
with:
103112
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
113+
- run: bun install --frozen-lockfile
114+
- name: Run fallow audit
115+
id: audit
116+
# `bun install` above made `bunx fallow` resolve from node_modules, so
117+
# we don't re-download fallow each run. The script disables `errexit`
118+
# so the audit's non-zero exit (on findings) doesn't abort before we
119+
# write the exit code to the step output.
120+
run: |
121+
set +e
122+
bunx fallow audit --base origin/main --fail-on-issues \
123+
--format pr-comment-github \
124+
> /tmp/fallow-comment.md
125+
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
126+
- name: Post sticky comment (findings)
127+
if: steps.audit.outputs.exit_code != '0'
128+
uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.1
129+
with:
130+
# `header` matches fallow's built-in `<!-- fallow-id: fallow-results -->`
131+
# sentinel so subsequent runs update the same comment.
132+
header: fallow-results
133+
path: /tmp/fallow-comment.md
134+
- name: Remove stale sticky comment (clean run)
135+
if: steps.audit.outputs.exit_code == '0'
136+
uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2.9.1
137+
with:
138+
header: fallow-results
139+
delete: true
140+
- name: Fail if audit found issues
141+
if: steps.audit.outputs.exit_code != '0'
142+
run: |
143+
echo "::error::Fallow audit found new issues — see the PR comment above for details."
144+
exit 1
107145
108146
format:
109147
name: Format

0 commit comments

Comments
 (0)