Skip to content

Commit d35ad08

Browse files
committed
feat(sync-snippets): switch to consumer-declared entrypoints
The CLI no longer asks each sdk.yaml which file in the consumer to rewrite (see launchdarkly/sdk-meta#405); instead the consumer declares its own list of search roots. Plumb that through: - New required input `entrypoints` (newline-separated list of directories, relative to $GITHUB_WORKSPACE). - Render step parses the input into individual `--entrypoint=` flags and passes them to `snippets render`. - Empty / whitespace-only lines are tolerated and skipped; an empty list fails loudly. - README + the in-action usage block updated to show the new shape. Consumer wiring becomes: - uses: launchdarkly/gh-actions/actions/sync-snippets@main with: entrypoints: | static/ld/components/getStarted github-token: ${{ secrets.GITHUB_TOKEN }}
1 parent 7356550 commit d35ad08

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

actions/sync-snippets/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
- uses: actions/checkout@v4
2828
- uses: launchdarkly/gh-actions/actions/sync-snippets@main
2929
with:
30+
entrypoints: |
31+
static/ld/components/getStarted
3032
github-token: ${{ secrets.GITHUB_TOKEN }}
3133
```
3234
@@ -35,13 +37,14 @@ jobs:
3537
1. Resolves the latest `snippets/vX.Y.Z` GitHub Release on `launchdarkly/sdk-meta` (override with `version:` if you need to pin or roll back).
3638
2. Downloads the platform-specific binary archive plus the cosign signature and certificate.
3739
3. Verifies the signature is keyless-signed by `launchdarkly/sdk-meta`'s `release-please` workflow on `main` via GitHub OIDC.
38-
4. Runs `snippets render --target=<adapter> --out=$GITHUB_WORKSPACE`. The binary embeds the canonical `sdks/` tree at build time — no separate snippet fetch.
40+
4. Runs `snippets render --target=<adapter> --entrypoint=<dir>...` with one `--entrypoint` flag per non-empty line of the `entrypoints:` input. The binary embeds the canonical `sdks/` tree at build time — no separate snippet fetch. The renderer walks each entrypoint recursively, picks up files with extensions it understands (`.tsx`/`.jsx`/`.ts`/`.js`/`.mdx`) that contain the `SDK_SNIPPET:RENDER:` sentinel, and skips junk dirs (`node_modules`, `.git`, `dist`, `build`, ...).
3941
5. Opens (or updates) a pull request with the rewritten files. If `render` produced no diff, the action exits 0 without opening a PR.
4042

4143
## Inputs
4244

4345
| Name | Default | Description |
4446
|---|---|---|
47+
| `entrypoints` | (required) | Newline-separated list of consumer-checkout directories the renderer should walk for snippet markers. Paths resolve against `$GITHUB_WORKSPACE`. |
4548
| `version` | `latest` | Release tag to install (e.g. `snippets/v0.3.0`). `latest` resolves to the most recent published `snippets/*` release. |
4649
| `target` | `ld-application` | Adapter target. `ld-application` for gonfalon. Future targets (e.g. `ld-docs`) plug in here. |
4750
| `branch` | `chore/sync-sdk-snippets` | Branch the action commits the rendered diff to. |

actions/sync-snippets/action.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ description: |
2424
- uses: actions/checkout@v4
2525
- uses: launchdarkly/gh-actions/actions/sync-snippets@main
2626
with:
27+
entrypoints: |
28+
static/ld/components/getStarted
2729
github-token: ${{ secrets.GITHUB_TOKEN }}
2830
2931
inputs:
@@ -40,6 +42,16 @@ inputs:
4042
uses TSX render markers); future targets (e.g. `ld-docs`) plug in here.
4143
required: false
4244
default: 'ld-application'
45+
entrypoints:
46+
description: |
47+
Newline-separated list of consumer-checkout directories the renderer
48+
should walk for snippet markers. Paths are resolved relative to
49+
$GITHUB_WORKSPACE (so a top-level `static/ld/components/getStarted` is
50+
what gonfalon would pass). Each line becomes one `--entrypoint=` flag
51+
to the CLI; the CLI walks each recursively, opens files with extensions
52+
it understands (.tsx/.jsx/.ts/.js/.mdx), and skips junk dirs
53+
(node_modules, .git, dist, build, ...).
54+
required: true
4355
branch:
4456
description: 'Branch the action commits the rendered diff to.'
4557
required: false
@@ -173,12 +185,30 @@ runs:
173185
174186
# 6. Render against the consumer checkout. `snippets` is now on $PATH.
175187
# The CLI loads the canonical sdks/ tree from the binary's embedded FS
176-
# — no separate snippet sources to fetch.
188+
# — no separate snippet sources to fetch. Each line of the
189+
# `entrypoints:` input becomes one `--entrypoint=` flag (relative paths
190+
# resolve against $GITHUB_WORKSPACE).
177191
- name: 'Render snippets'
178192
shell: bash
193+
env:
194+
ENTRYPOINTS: ${{ inputs.entrypoints }}
179195
run: |
196+
set -euo pipefail
180197
snippets version
181-
snippets render --target='${{ inputs.target }}' --out="$GITHUB_WORKSPACE"
198+
cd "$GITHUB_WORKSPACE"
199+
args=()
200+
while IFS= read -r line; do
201+
# Strip surrounding whitespace; skip empty lines.
202+
line="${line#"${line%%[![:space:]]*}"}"
203+
line="${line%"${line##*[![:space:]]}"}"
204+
[ -z "$line" ] && continue
205+
args+=("--entrypoint=$line")
206+
done <<< "$ENTRYPOINTS"
207+
if [ ${#args[@]} -eq 0 ]; then
208+
echo "::error::sync-snippets: at least one non-empty entrypoint must be provided"
209+
exit 1
210+
fi
211+
snippets render --target="${{ inputs.target }}" "${args[@]}"
182212
183213
# 7. Detect whether render touched anything. Empty diff means the consumer
184214
# is already current; we exit cleanly with no PR.

0 commit comments

Comments
 (0)