Skip to content

Commit 29928de

Browse files
authored
fix: convert from reusable workflow to composite action (#2)
The v1.0.0 reusable workflow used a two-checkout pattern with ${{ github.workflow_ref }} to pull in its own scripts. That context variable — inside a reusable workflow — resolves to the CALLER's workflow ref, not the callee's, which produces an invalid git refspec when fed to actions/checkout as 'ref:'. The pattern cannot work: there is no reusable-workflow context that exposes the caller's pinned ref back to the callee. Composite actions have ${{ github.action_path }} which is the canonical way to ship scripts alongside an action. Caller boilerplate grows slightly (own checkout + uses: step) but the form is structurally sound. Breaking API changes from v1.0.0: - Caller syntax: jobs.foo.uses: -> jobs.foo.steps[].uses: (plus own checkout) - Secrets become inputs: secrets.GH_PAT -> inputs.gh-pat, etc. - Still passed via ${{ secrets.FOO }} at call site for masking. README updated for new caller syntax. Scripts unchanged. v1.0.0 and v1 tags will be force-moved to this commit; beacon's caller (currently at broken v1 syntax) will be updated in a follow-up PR.
1 parent 417fbca commit 29928de

4 files changed

Lines changed: 233 additions & 247 deletions

File tree

.github/workflows/check-action-versions.yml

Lines changed: 0 additions & 214 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
!CONTRIBUTING.md
3535
!LICENSE
3636
!README.md
37+
!action.yml
3738
!mise.toml
3839

3940
# Allow markdown anywhere

README.md

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Check Action Versions
22

3-
A reusable GitHub workflow that audits the SHA-pinned `uses:` references in your workflow files, resolves each action's latest strict-semver release, and opens a security issue + automated PR when anything is outdated.
3+
A composite GitHub Action that audits the SHA-pinned `uses:` references in your workflow files, resolves each action's latest strict-semver release, and opens a security issue + automated PR when anything is outdated.
44

55
- Runs on your schedule (weekly is typical)
66
- Creates a single tracking issue, updates it on each run
@@ -25,23 +25,23 @@ on:
2525

2626
jobs:
2727
check:
28-
uses: nerdalytics/check-action-versions/.github/workflows/check-action-versions.yml@v1
29-
with:
30-
committer-name: your-bot-username
31-
committer-email: your-bot-email@example.com
32-
secrets:
33-
GH_PAT: ${{ secrets.YOUR_PAT_SECRET_NAME }}
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
31+
with:
32+
token: ${{ secrets.YOUR_PAT_SECRET_NAME }}
33+
- uses: nerdalytics/check-action-versions@v1
34+
with:
35+
committer-name: your-bot-username
36+
committer-email: your-bot-email@example.com
37+
gh-pat: ${{ secrets.YOUR_PAT_SECRET_NAME }}
3438
```
3539
3640
That's the minimum. Everything else is optional — see below.
3741
3842
## Permissions
3943
40-
Your caller workflow must also declare the permissions the action needs. GitHub
41-
applies the **intersection** of caller job-level permissions and the reusable
42-
workflow's declared permissions — if your caller doesn't grant them, the issue
43-
and PR steps will fail at runtime even though the action declares them
44-
internally. The Quickstart above shows the required top-level block:
44+
Your caller workflow needs `contents: write`, `issues: write`, `pull-requests: write`. Declare at workflow or job level.
4545

4646
```yaml
4747
permissions:
@@ -50,11 +50,6 @@ permissions:
5050
pull-requests: write
5151
```
5252

53-
Declaring them at workflow-level (as in Quickstart) applies by default to all
54-
jobs in the caller. If you use job-level `permissions:` overrides anywhere,
55-
make sure the job that calls this action retains write access to contents,
56-
issues, and pull-requests.
57-
5853
## Inputs
5954

6055
### Required
@@ -142,26 +137,28 @@ How automated commits are cryptographically signed:
142137
- `ssh` — SSH signing. Recommended when you want verified commits. See [Signing](#signing) below.
143138
- `gpg` — GPG signing. Supported for repos with existing GPG infrastructure, but SSH is simpler to set up and maintain.
144139

145-
## Secrets
140+
## Secret-bearing inputs
141+
142+
Composite actions don't have a separate `secrets:` block — secret values are passed as regular inputs. Always reference them via `${{ secrets.NAME }}` at the call site so GitHub masks the value in logs.
146143

147-
### `GH_PAT` — required
144+
### `gh-pat` — required
148145

149146
A Personal Access Token (classic) or fine-grained PAT with `repo` and `workflow` scopes on the target repo.
150147

151148
**Why not `GITHUB_TOKEN`?** PRs opened by `GITHUB_TOKEN` do not trigger workflows. Your CI (lint, test, build) will not run on the automated PR, so you won't know if the update broke anything. A PAT from a bot account works around this.
152149

153-
Store as a repo or org secret and pass via `secrets: GH_PAT:`.
150+
Store as a repo or org secret and pass via `gh-pat: ${{ secrets.YOUR_PAT_SECRET_NAME }}`.
154151

155-
### `SIGNING_KEY` — optional
152+
### `signing-key` — optional
156153

157154
Required iff `signing-method` is non-empty. Validated at runtime; the action fails fast with a clear error if set to `ssh` or `gpg` without a key.
158155

159156
- For `ssh`: the full private key including the `-----BEGIN OPENSSH PRIVATE KEY-----` header and footer
160157
- For `gpg`: an armored private key block (`gpg --armor --export-secret-keys <key-id>`)
161158

162-
### `SIGNING_PASSPHRASE` — optional
159+
### `signing-passphrase` — optional
163160

164-
The passphrase protecting `SIGNING_KEY`. Leave unset if the key is unencrypted.
161+
The passphrase protecting `signing-key`. Leave unset if the key is unencrypted.
165162

166163
## Signing
167164

@@ -201,10 +198,8 @@ One-time, per repo or per org:
201198
```yaml
202199
with:
203200
signing-method: ssh
204-
secrets:
205-
GH_PAT: ${{ secrets.YOUR_PAT_SECRET_NAME }}
206-
SIGNING_KEY: ${{ secrets.SSH_SIGNING_KEY }}
207-
SIGNING_PASSPHRASE: ${{ secrets.SSH_SIGNING_KEY_PASSPHRASE }}
201+
signing-key: ${{ secrets.SSH_SIGNING_KEY }}
202+
signing-passphrase: ${{ secrets.SSH_SIGNING_KEY_PASSPHRASE }}
208203
```
209204

210205
5. **Verify** by triggering `workflow_dispatch` manually. The resulting commit in the automated PR should display "Verified" with a tooltip naming your bot account.
@@ -215,7 +210,7 @@ One-time, per repo or per org:
215210
2. Export the private key: `gpg --armor --export-secret-keys <key-id>`
216211
3. Register the **public** key on the bot's GitHub account under "SSH and GPG keys"
217212
4. Store private key + passphrase as secrets
218-
5. Pass `signing-method: gpg` and the secrets as shown in Quickstart
213+
5. Pass `signing-method: gpg`, `signing-key: ${{ secrets.GPG_PRIVATE_KEY }}`, and `signing-passphrase: ${{ secrets.GPG_PASSPHRASE }}` in the `with:` block of the action step
219214

220215
The action sets up `gpg-agent` with a preset passphrase and configures `git commit.gpgsign true` for the duration of the job.
221216

@@ -257,14 +252,14 @@ If you want full determinism despite the irony, pin to a specific release tag or
257252

258253
## Troubleshooting
259254

260-
**"Secret GH_PAT is required but not supplied"**
261-
Your caller workflow is missing `secrets: GH_PAT: ...`. Add it.
255+
**"Input required and not supplied: gh-pat"**
256+
Your caller workflow is missing `gh-pat: ${{ secrets.YOUR_PAT_SECRET_NAME }}` in the `with:` block. Add it.
262257

263-
**"signing-method is 'ssh' but no SIGNING_KEY secret was supplied"**
264-
Either pass `SIGNING_KEY` or set `signing-method` to empty.
258+
**"signing-method is 'ssh' but signing-key input is empty"**
259+
Either pass `signing-key` or set `signing-method` to empty.
265260

266261
**PR opens but CI doesn't run on it**
267-
`GH_PAT` is actually `GITHUB_TOKEN`. Use a PAT from a bot account — see the `GH_PAT` section above.
262+
`gh-pat` is actually `GITHUB_TOKEN`. Use a PAT from a bot account — see the `gh-pat` section above.
268263

269264
**Commit shows "Unverified" despite `signing-method: ssh`**
270265
The public key registered on the bot account is marked as an Authentication Key, not a Signing Key. GitHub distinguishes the two. Re-add it with the correct type.

0 commit comments

Comments
 (0)