Skip to content

Commit 5555b39

Browse files
committed
adjusted workflows an and naming
1 parent ae7c3f8 commit 5555b39

6 files changed

Lines changed: 166 additions & 17 deletions

File tree

.github/workflows/ai-code-review.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Reusable workflow: AI code review.
2-
# Consumers call this via `uses: your-org/ff-sec-action/.github/workflows/ai-code-review.yml@v1`.
2+
# Consumers call this via `uses: filecoin-project/ff-sec-actions/.github/workflows/ai-code-review.yml@v1`.
33
# NOTE: the `uses:` ref on the action step below must be kept in sync with release tags
44
# (reusable workflows cannot reference sibling actions by relative path without a checkout).
55
name: AI Code Review (reusable)
@@ -62,7 +62,7 @@ jobs:
6262
# never executes PR code.
6363
- name: AI code review
6464
id: ai-review
65-
uses: your-org/ff-sec-action/actions/ai-code-review@v1
65+
uses: filecoin-project/ff-sec-actions/actions/ai-code-review@v1
6666
with:
6767
anthropic-api-key: ${{ secrets.anthropic-api-key }}
6868
model: ${{ inputs.model }}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Manual test harness for the ai-code-review action.
2+
# Run from the Actions tab (workflow_dispatch) against any PR number.
3+
#
4+
# This checks out THIS repo at the ref you dispatch from and runs the LOCAL
5+
# action (./actions/ai-code-review), so you can test branch changes before
6+
# tagging a release — unlike the reusable workflow, which uses the pinned @v1.
7+
#
8+
# Notes:
9+
# - Requires the ANTHROPIC_API_KEY secret on this repo (or via the org).
10+
# - `repo` defaults to this repository. To review a PR in ANOTHER repo, the
11+
# default github.token won't have access — add a GH_PAT secret (fine-grained
12+
# PAT with Pull requests read/write on the target repo) and it is used
13+
# automatically when present.
14+
# - post-comment defaults to "false" for safe testing: results go to the job
15+
# summary only. Flip to "true" to exercise the sticky-comment path.
16+
name: AI Code Review (manual)
17+
18+
on:
19+
workflow_dispatch:
20+
inputs:
21+
pr-number:
22+
description: PR number to review
23+
required: true
24+
repo:
25+
description: owner/repo containing the PR (blank = this repo)
26+
required: false
27+
default: ""
28+
domain:
29+
description: Domain prompt (prompts/<domain>.md)
30+
required: false
31+
default: filecoin
32+
model:
33+
description: Claude model ID
34+
required: false
35+
default: claude-opus-4-8
36+
effort:
37+
description: "Effort: low | medium | high | max"
38+
required: false
39+
default: high
40+
fail-on-severity:
41+
description: "Fail job at/above: none | critical | high | medium | low"
42+
required: false
43+
default: none
44+
post-comment:
45+
description: Post the sticky PR comment (job summary always written)
46+
required: false
47+
type: choice
48+
options: ["false", "true"]
49+
default: "false"
50+
51+
jobs:
52+
review:
53+
runs-on: ubuntu-latest
54+
permissions:
55+
contents: read
56+
pull-requests: write
57+
steps:
58+
- name: Checkout this repo (the action + prompts under test)
59+
uses: actions/checkout@v4
60+
61+
- name: AI code review
62+
id: ai
63+
uses: ./actions/ai-code-review
64+
with:
65+
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
66+
github-token: ${{ secrets.GH_PAT || github.token }}
67+
pr-number: ${{ inputs.pr-number }}
68+
repo: ${{ inputs.repo }}
69+
domain: ${{ inputs.domain }}
70+
model: ${{ inputs.model }}
71+
effort: ${{ inputs.effort }}
72+
fail-on-severity: ${{ inputs.fail-on-severity }}
73+
post-comment: ${{ inputs.post-comment }}
74+
75+
- name: Report outputs
76+
if: always()
77+
run: |
78+
echo "findings-count: ${{ steps.ai.outputs.findings-count }}"
79+
echo "highest-severity: ${{ steps.ai.outputs.highest-severity }}"
80+
echo "findings-json: ${{ steps.ai.outputs.findings-json }}"

README.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Consumer repositories reference this repo for **composite actions**, **reusable
99
workflows**, and **standalone scripts**, so review logic, prompts, and policy
1010
live in one place and roll out to every repo by bumping a tag.
1111

12-
Replace `your-org` throughout with the GitHub organization this repo lives in.
12+
Replace `filecoin-project` throughout with the GitHub organization this repo lives in.
1313

1414
## Repository layout
1515

@@ -22,7 +22,8 @@ ff-sec-action/
2222
│ ├── review.sh
2323
│ └── schema.json
2424
├── .github/workflows/ # Reusable workflows (whole job, workflow_call)
25-
│ └── ai-code-review.yml
25+
│ ├── ai-code-review.yml
26+
│ └── manual-ai-code-review.yml # workflow_dispatch test harness (runs the local action)
2627
├── scripts/ # Standalone scripts runnable outside any action
2728
├── prompts/ # Domain knowledge as data, not code
2829
│ ├── base-reviewer.md # Always included: review behavior + output rules
@@ -58,7 +59,7 @@ concurrency:
5859
jobs:
5960
review:
6061
if: ${{ !github.event.pull_request.draft }}
61-
uses: your-org/ff-sec-action/.github/workflows/ai-code-review.yml@v1
62+
uses: filecoin-project/ff-sec-actions/.github/workflows/ai-code-review.yml@v1
6263
with:
6364
domain: filecoin # picks prompts/filecoin.md
6465
fail-on-severity: none # or: critical | high | medium
@@ -86,7 +87,7 @@ jobs:
8687
contents: read
8788
pull-requests: write # needed to post the review comment
8889
steps:
89-
- uses: your-org/ff-sec-action/actions/ai-code-review@v1
90+
- uses: filecoin-project/ff-sec-actions/actions/ai-code-review@v1
9091
id: ai
9192
with:
9293
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
@@ -112,7 +113,7 @@ Two patterns:
112113
steps:
113114
- uses: actions/checkout@v4
114115
with:
115-
repository: your-org/ff-sec-action
116+
repository: filecoin-project/ff-sec-actions
116117
ref: v1 # or a full SHA for the strictest pinning
117118
path: .ff-sec
118119
- run: bash .ff-sec/scripts/<script>.sh
@@ -123,7 +124,7 @@ steps:
123124
**b. Locally, from a clone:**
124125

125126
```sh
126-
git clone --depth 1 --branch v1 https://github.com/your-org/ff-sec-action
127+
git clone --depth 1 --branch v1 https://github.com/filecoin-project/ff-sec-actions
127128
bash ff-sec-action/scripts/<script>.sh
128129
```
129130

@@ -132,7 +133,7 @@ and fails fast with a clear message when one is missing. Example — running the
132133
AI review against any PR from your terminal:
133134

134135
```sh
135-
PR_NUMBER=123 REPO=your-org/some-repo \
136+
PR_NUMBER=123 REPO=filecoin-project/some-repo \
136137
ANTHROPIC_API_KEY=... GH_TOKEN=$(gh auth token) \
137138
PROMPT_FILE=prompts/filecoin.md BASE_PROMPT_FILE=prompts/base-reviewer.md \
138139
SCHEMA_FILE=actions/ai-code-review/scripts/schema.json \
@@ -165,6 +166,8 @@ executes PR code**.
165166
|---|---|---|
166167
| `anthropic-api-key` | — (required) | Pass from secrets |
167168
| `github-token` | `${{ github.token }}` | Needs `pull-requests: write` to comment |
169+
| `pr-number` | current PR event | Set explicitly for `workflow_dispatch` runs |
170+
| `repo` | current repository | Cross-repo runs need a `github-token` with access to that repo |
168171
| `model` | `claude-opus-4-8` | Any current Claude model ID |
169172
| `domain` | `filecoin` | Resolves `prompts/<domain>.md` |
170173
| `prompt-file` | `""` | Absolute path override; beats `domain` |
@@ -253,7 +256,7 @@ Guidelines:
253256
this repo: it owns `runs-on`, `permissions` (least privilege), and secret
254257
plumbing — the action owns the logic. That keeps both surfaces in sync.
255258
- Reference the sibling action by **full path with a tag**
256-
(`uses: your-org/ff-sec-action/actions/<name>@v1`), not a relative path —
259+
(`uses: filecoin-project/ff-sec-actions/actions/<name>@v1`), not a relative path —
257260
relative references don't resolve without a checkout. Keep the tag in sync
258261
when releasing (grep for `@v1` before tagging).
259262
- Mirror the composite action's inputs 1:1 with the same names and defaults so
@@ -309,8 +312,15 @@ Guidelines:
309312
- **Local dry-run:** every script must be runnable locally with env vars (see
310313
[Standalone scripts](#3-standalone-scripts)) — use a real PR in a sandbox
311314
repo and `POST_COMMENT=false`-style flags.
312-
- **End-to-end:** open a PR against a sandbox repo whose workflow points at
313-
your branch: `uses: your-org/ff-sec-action/actions/<name>@<your-branch>`.
315+
- **Manual run (fastest end-to-end):** Actions tab → "AI Code Review (manual)"
316+
→ Run workflow. Pick your branch, give it a PR number (any PR in this repo,
317+
or another repo via the `repo` input + a `GH_PAT` secret). It checks out the
318+
selected branch and runs the **local** action, so branch changes are tested
319+
before any tag exists. `post-comment` defaults to `false` — results land in
320+
the job summary.
321+
- **End-to-end from a consumer:** open a PR against a sandbox repo whose
322+
workflow points at your branch:
323+
`uses: filecoin-project/ff-sec-actions/actions/<name>@<your-branch>`.
314324
Verify the comment, job summary, outputs, and the failure gate.
315325
- PRs to this repo get reviewed by the org security team (add a `CODEOWNERS`
316326
entry for your action's directory if you want ownership).

actions/ai-code-review/action.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ inputs:
1313
description: Token used to read the PR diff and post the review comment.
1414
required: false
1515
default: ${{ github.token }}
16+
pr-number:
17+
description: PR number to review. Defaults to the current pull_request event (set explicitly for workflow_dispatch runs).
18+
required: false
19+
default: ""
20+
repo:
21+
description: owner/repo containing the PR. Defaults to the current repository (cross-repo runs need a github-token with access to that repo).
22+
required: false
23+
default: ""
1624
model:
1725
description: Claude model ID.
1826
required: false
@@ -81,11 +89,11 @@ runs:
8189
DOMAIN: ${{ inputs.domain }}
8290
PROMPT_FILE_OVERRIDE: ${{ inputs.prompt-file }}
8391
ACTION_PATH: ${{ github.action_path }}
84-
PR_NUMBER: ${{ github.event.pull_request.number }}
85-
REPO: ${{ github.repository }}
92+
PR_NUMBER: ${{ inputs.pr-number || github.event.pull_request.number }}
93+
REPO: ${{ inputs.repo || github.repository }}
8694
run: |
8795
if [ -z "${PR_NUMBER}" ]; then
88-
echo "::error::ai-code-review must run on a pull_request event."
96+
echo "::error::No PR to review: run on a pull_request event or set the pr-number input."
8997
exit 1
9098
fi
9199
if [ -n "${PROMPT_FILE_OVERRIDE}" ]; then

examples/consumer-ai-code-review.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
# Option A — reusable workflow (recommended: permissions pre-wired)
1515
review:
1616
if: ${{ !github.event.pull_request.draft }}
17-
uses: your-org/ff-sec-action/.github/workflows/ai-code-review.yml@v1
17+
uses: filecoin-project/ff-sec-actions/.github/workflows/ai-code-review.yml@v1
1818
with:
1919
domain: filecoin
2020
fail-on-severity: none # set to `critical` once the team trusts the signal
@@ -29,7 +29,7 @@ jobs:
2929
# contents: read
3030
# pull-requests: write
3131
# steps:
32-
# - uses: your-org/ff-sec-action/actions/ai-code-review@v1
32+
# - uses: filecoin-project/ff-sec-actions/actions/ai-code-review@v1
3333
# id: ai
3434
# with:
3535
# anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Manual (on-demand) AI review for a CONSUMER repo.
2+
# Drop this into the consumer repo as .github/workflows/ai-review-manual.yml,
3+
# then: Actions tab -> "AI Code Review (manual)" -> Run workflow -> enter a PR number.
4+
# Or from the CLI: gh workflow run "AI Code Review (manual)" -f pr-number=123
5+
#
6+
# Requirements in the consumer repo:
7+
# - ANTHROPIC_API_KEY secret visible to this repo (org secret recommended)
8+
# - If ff-sec-actions is private: it must allow org repo access
9+
# (ff-sec-actions Settings -> Actions -> General -> Access)
10+
# - This file must be on the default branch before it appears in the Actions tab
11+
#
12+
# Use @main until a v1 tag exists in ff-sec-actions; switch to @v1 after tagging.
13+
name: AI Code Review (manual)
14+
15+
on:
16+
workflow_dispatch:
17+
inputs:
18+
pr-number:
19+
description: PR number in THIS repo to review
20+
required: true
21+
domain:
22+
description: Domain prompt (prompts/<domain>.md in ff-sec-actions)
23+
required: false
24+
default: filecoin
25+
post-comment:
26+
description: Post the sticky PR comment (job summary always written)
27+
required: false
28+
type: choice
29+
options: ["true", "false"]
30+
default: "true"
31+
32+
jobs:
33+
review:
34+
runs-on: ubuntu-latest
35+
permissions:
36+
contents: read
37+
pull-requests: write
38+
steps:
39+
# No checkout needed: the action fetches the PR diff via the GitHub API.
40+
- uses: filecoin-project/ff-sec-actions/actions/ai-code-review@main
41+
id: ai
42+
with:
43+
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
44+
pr-number: ${{ inputs.pr-number }}
45+
domain: ${{ inputs.domain }}
46+
post-comment: ${{ inputs.post-comment }}
47+
48+
- if: always()
49+
run: |
50+
echo "findings-count: ${{ steps.ai.outputs.findings-count }}"
51+
echo "highest-severity: ${{ steps.ai.outputs.highest-severity }}"

0 commit comments

Comments
 (0)