|
1 | | -# 🐸 Bumpy CI check |
2 | | -# checks for missing bump files and posts/updates a PR comment with the release plan |
| 1 | +# 🐸 Bumpy CI check (dogfood) |
| 2 | +# Runs our own unreleased bumpy on every PR and renders the release-plan comment as an |
| 3 | +# artifact. Runs on the UNPRIVILEGED `pull_request` event, so it's safe to build and run |
| 4 | +# the PR's own bumpy (fork or not) — there's no write token or secrets to protect here. |
| 5 | +# Posting the comment on fork PRs is the privileged half and lives in bumpy-comment.yaml |
| 6 | +# (workflow_run). A normal project just adds |
| 7 | +# bunx @varlock/bumpy ci check --emit-comment ./bumpy-comment |
| 8 | +# to its existing CI workflow. |
3 | 9 | # |
4 | | -# ⚠️ NOTE - DO NOT COPY THIS FILE |
5 | | -# instead look at the recommended workflow in the docs |
| 10 | +# ⚠️ DO NOT COPY THIS FILE — see the recommended setup in the docs: |
6 | 11 | # ➡️ https://bumpy.varlock.dev/blob/main/docs/github-actions.md ⬅️ |
7 | | -# |
8 | | -# This repo builds and runs its OWN unreleased bumpy so we dogfood the current |
9 | | -# CLI on every PR. Two jobs, split by trust level: |
10 | | -# - non-fork PRs build and run the PR's OWN bumpy, so a PR previews its own |
11 | | -# ci-check changes. Safe because the code comes from this repo. |
12 | | -# - fork PRs build and run MAIN's bumpy and only READ the PR via `--cwd ./pr`, |
13 | | -# so no untrusted code ever touches the pull_request_target write token. |
14 | | -# A normal project just runs `bunx @varlock/bumpy@latest ci check --cwd ./pr`. |
15 | | - |
16 | 12 | name: Bumpy Check |
17 | 13 |
|
18 | | -on: pull_request_target # < necessary so it can post comments on fork PRs |
| 14 | +on: pull_request |
19 | 15 |
|
20 | 16 | permissions: |
21 | | - pull-requests: write |
| 17 | + pull-requests: write # same-repo PRs comment directly; fork PRs are read-only (the poster handles those) |
22 | 18 | contents: read |
23 | 19 |
|
24 | 20 | jobs: |
25 | | - # Non-fork PRs (trusted): build and run the PR's OWN bumpy so it dogfoods its |
26 | | - # own changes. `--cwd .` acknowledges that the current checkout is trusted. |
27 | | - check-local: |
28 | | - if: github.event.pull_request.head.repo.full_name == github.repository |
| 21 | + check: |
29 | 22 | runs-on: ubuntu-latest |
30 | 23 | steps: |
31 | | - - uses: actions/checkout@v6 |
| 24 | + - uses: actions/checkout@v7 |
32 | 25 | with: |
33 | | - ref: ${{ github.event.pull_request.head.sha }} |
34 | 26 | fetch-depth: 0 # history to diff bump files against the PR base branch |
35 | 27 | - uses: oven-sh/setup-bun@v2 |
36 | 28 | - run: bun install |
37 | | - # Build first since we run the local built version of bumpy. |
38 | 29 | - run: bun run --filter @varlock/bumpy build |
39 | | - # Re-install so the freshly-built CLI bin is linked. |
40 | | - - run: bun install |
41 | | - - run: bunx @varlock/bumpy ci check --cwd . |
| 30 | + - run: bun install # link the freshly-built CLI bin |
| 31 | + - run: bunx @varlock/bumpy ci check --emit-comment ./bumpy-comment |
42 | 32 | env: |
43 | 33 | GH_TOKEN: ${{ github.token }} |
44 | | - |
45 | | - # Fork PRs (untrusted): build and run MAIN's bumpy from a trusted checkout and |
46 | | - # only READ the PR head via `--cwd ./pr` — never install/build/run fork code. |
47 | | - check-fork: |
48 | | - if: github.event.pull_request.head.repo.full_name != github.repository |
49 | | - runs-on: ubuntu-latest |
50 | | - steps: |
51 | | - # TRUSTED base checkout (main) — bumpy is built and run from here. |
52 | | - - uses: actions/checkout@v6 |
53 | | - with: |
54 | | - ref: main |
55 | | - persist-credentials: false |
56 | | - # UNTRUSTED PR head into ./pr — only READ via --cwd, never built or run. |
57 | | - - uses: actions/checkout@v6 |
| 34 | + - uses: actions/upload-artifact@v4 |
| 35 | + if: always() # upload even when the check fails — the comment explains why |
58 | 36 | with: |
59 | | - ref: ${{ github.event.pull_request.head.sha }} |
60 | | - path: pr |
61 | | - persist-credentials: false |
62 | | - - uses: oven-sh/setup-bun@v2 |
63 | | - - run: bun install |
64 | | - - run: bun run --filter @varlock/bumpy build |
65 | | - - run: bun install |
66 | | - # bunx runs from the trusted root; bumpy reads the PR's bump files via --cwd. |
67 | | - - run: bunx @varlock/bumpy ci check --cwd ./pr |
68 | | - env: |
69 | | - GH_TOKEN: ${{ github.token }} |
| 37 | + name: bumpy-comment |
| 38 | + path: ./bumpy-comment |
0 commit comments