Commit 79eba0d
authored
Add action template engine (#48)
Generate flat, self-contained release actions from templates.
## Why
This repo ships composite actions that other SDK repos pin by **SHA**.
GitHub
resolves a `./actions/...` path against the **calling** repo's workspace
— so a
composite action fetched by SHA that internally calls a sibling action
fails:
```
Can't find 'action.yml' under '.../braintrust-sdk-ruby/actions/release/lang/ruby/rubygems-push'
```
Our release pipeline nested 4–5 levels of `uses: ./actions/...`, so it
broke for
every external consumer. There's no "group `if:`" or sub-action trick
that avoids
this (confirmed against the GitHub Actions docs) — the only fix is to
**not nest**.
## What changed
`actions/` is now **generated, flat output**. Source lives in
`templates/`; a
small ERB generator inlines reusable **steps** into each **action**, so
every
shipped `action.yml` is self-contained — no intra-repo `uses:`, only
`run:` steps
and marketplace actions. A single SHA pin now pulls in the whole chain,
no
transitive bumping.
**Before** — `publish` delegated to siblings (breaks when pinned
externally):
```yaml
- uses: ./actions/release/lang/ruby/rubygems-push # ← resolves in the CALLER's repo → 404
- uses: ./actions/release/create-github-release
- uses: ./actions/release/lang/ruby/notify-published
```
**After** — `publish` is one flat action, and its template reads like
the pipeline:
```erb
- uses: actions/checkout@...
if: ${{ inputs.checkout == 'true' }}
<%= render_step('lang/ruby/setup') %>
<%= render_step('release/lang/ruby/rubygems-push') %>
<%= render_step('release/create-github-release') %>
<%= render_step('release/lang/ruby/notify-published') %>
<%= render_step('release/lang/ruby/on-failure', if: "${{ failure() }}") %>
```
`render_step` inlines each step's YAML. Control flow stays in the
action: pure
"do" steps, then one terminal `on-failure`. Since GitHub can't guard a
*group* of
steps, `render_step(if:)` **stamps the condition onto every step it
expands** —
so the generated `on-failure` fans out to `env-dump` + `notify-failure`,
each
carrying `if: ${{ failure() }}`. Everything else a step decides ("Slack
configured?", "dry run?") is a shell `exit 0` self-guard, so there's
never a
condition to merge.
Result: **4 flat actions** composed from **11 reusable steps**, zero
intra-repo
`uses:`.
## Usage
- **Consumers** copy the canonical workflow (`release-ruby.yml`) into
their repo,
adapt the marked sections, and pin the actions by SHA. (README)
- **Contributors** edit `templates/`, run `rake generate` (renders +
validates
YAML *and* the GitHub Action schema), and commit `templates/` +
`actions/`
together. CI (`rake ci:actions`) fails if they drift. Toolchain is one
`mise install`. (CONTRIBUTING)
## Validation
End-to-end dry run of the generated actions against the `bt-fake` gem
(`release-ruby.yml`) **passes** on this branch.1 parent 71bbb60 commit 79eba0d
35 files changed
Lines changed: 2202 additions & 695 deletions
File tree
- .github/workflows
- actions
- lang/ruby/env-dump
- release
- create-github-release
- lang/ruby
- notify-published
- on-failure
- publish
- rubygems-push
- validate
- notify-failure
- notify-pending
- notify-published
- prepare
- validate
- slack/send
- scripts
- templates
- actions/release
- lang/ruby
- steps
- lang/ruby
- release
- lang/ruby
- slack
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 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 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
This file was deleted.
This file was deleted.
This file was deleted.
0 commit comments