Repository navigation
Commit a1be6a1
feat: run-script AWS role, SSH key and uv cache, and fix its pre-commit cache (#7)
### what
Add four optional parameters to the `run-script` workflow:
- `aws-role` (input): an AWS role to assume through GitHub OIDC with
`aws-actions/configure-aws-credentials` before the script runs.
`aws-region` (input, default `us-east-1`) sets its region.
- `SSH_PRIVATE_KEY` (secret): an SSH key for the script, written to
`~/.ssh/run-script-key` and named in `~/.ssh/config`, for example a
deploy
key pre-commit needs to clone a private hook repository.
- `uv-cache` (input, default false): restores uv's cache, falling back
to the
newest one when `uv.lock` moved, and prunes it with `uv cache prune
--ci`
and saves it off pull requests.
Neither cache is restored for pull requests from forks of a public
repository. A trusted run may have filled them with private packages or
clones of private hook repositories, which the fork's script could read.
Forks of a private repository belong to people who can already read it,
so
those still restore.
It also fixes the pre-commit cache. The key now covers the mise config
and
lockfiles and the selected `mise-env` as well as
`.pre-commit-config.yaml`,
and `PREK_HOME` is exported from `$HOME` in the script instead of set in
the
step's `env:`.
The workflow no longer sets permissions of its own, so its job runs with
exactly what the caller grants. OIDC needs `id-token: write`, and a
called
workflow can't be granted more than its caller has, so requesting it
here
would likely fail every caller that doesn't grant it. Existing callers
already grant `contents: read`, so they run as before. The caller's
grant
is now the only cap on the token `github-token` exposes, so the input no
longer calls it read-only, and the README says to grant nothing beyond
`contents: read` (plus `id-token: write` for `aws-role`).
### why
Jobs that install a project's dependencies from a private registry, or
whose pre-commit hooks come from a private repository, can't use
`run-script` today. Platform's Lint job needs both: AWS credentials for
CodeArtifact and the pre-commit deploy key. Installing its dependencies
on every run is also slow without uv's cache.
Hook environments are built with the toolchains mise installs, so a
Python
bump restored environments built against the old interpreter.
`PREK_HOME`
was the literal string `~/.cache/pre-commit`, since `env:` values don't
expand `~`, so prek wrote its environments to a `~` directory in the
checkout and the cache step saved an empty one.
### testing
actionlint, zizmor, ruff and codespell pass (`prek run --all-files`).
zizmor accepts the job without a permissions block. This repository's
own
CI runs on `run-script` with `pre-commit-cache`, so it exercises the
permissions change, the new pre-commit key and `PREK_HOME`. The AWS, SSH
and
uv cache steps run only once a caller passes them, and the fork check
only
on a fork's pull request.
### docs
The README's `run-script` section covers the new parameters, both caches
and when they're skipped, the permissions a caller must grant, and an
example caller.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>1 parent 48cc95e commit a1be6a1
2 files changed
Lines changed: 118 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | | - | |
| 23 | + | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
25 | 37 | | |
26 | 38 | | |
27 | 39 | | |
28 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
29 | 49 | | |
30 | 50 | | |
31 | 51 | | |
32 | | - | |
33 | | - | |
34 | 52 | | |
35 | 53 | | |
| 54 | + | |
36 | 55 | | |
37 | 56 | | |
38 | 57 | | |
| |||
49 | 68 | | |
50 | 69 | | |
51 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
52 | 90 | | |
53 | 91 | | |
54 | 92 | | |
55 | 93 | | |
56 | 94 | | |
57 | 95 | | |
58 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
59 | 106 | | |
60 | | - | |
| 107 | + | |
61 | 108 | | |
62 | 109 | | |
63 | 110 | | |
64 | 111 | | |
65 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
66 | 125 | | |
67 | 126 | | |
68 | 127 | | |
69 | 128 | | |
70 | 129 | | |
71 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
72 | 134 | | |
73 | 135 | | |
74 | 136 | | |
75 | | - | |
76 | | - | |
77 | 137 | | |
78 | | - | |
79 | | - | |
80 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
81 | 141 | | |
82 | 142 | | |
83 | 143 | | |
84 | 144 | | |
85 | 145 | | |
86 | 146 | | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
60 | 93 | | |
61 | 94 | | |
62 | 95 | | |
| |||
0 commit comments