-
Notifications
You must be signed in to change notification settings - Fork 1
ci: automate Figma Code Connect publish + validate #794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| name: 'Figma Code Connect' | ||
|
|
||
| # Keeps the Figma Code Connect mappings (libs/figma/*.figma.ts) in sync with | ||
| # Figma. Previously this was only ever run by hand — `@figma/code-connect` isn't | ||
| # even a declared dependency — so Dev Mode was only as fresh as the last person | ||
| # who remembered to run `figma connect publish` locally with a personal token. | ||
| # | ||
| # - On PRs touching the mappings: `parse` (validate every file locally, no | ||
| # token, no publish) so a broken mapping fails the PR instead of silently | ||
| # shipping stale code snippets. | ||
| # - On merge to main (or manual dispatch): `publish` the mappings to Figma so | ||
| # each connected component emits its `pds-*` example in Dev Mode. | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: ['**'] | ||
| paths: | ||
| - 'libs/figma/**' | ||
| - 'figma.config.json' | ||
| - '.github/workflows/code-connect.yml' | ||
| push: | ||
| branches: [main] | ||
| paths: | ||
| - 'libs/figma/**' | ||
| - 'figma.config.json' | ||
| - '.github/workflows/code-connect.yml' | ||
| workflow_dispatch: | ||
|
|
||
| concurrency: | ||
| group: code-connect-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| # Bump to upgrade the Code Connect CLI. Kept as an npx pin (not a package.json | ||
| # dependency) so this workflow stays self-contained and matches how the CLI is | ||
| # run today; promote to a pinned devDependency if it ever needs to run inside | ||
| # the normal build/lint pipeline. | ||
| # | ||
| # Minimum 1.4.4: `--exit-on-unreadable-files` is only respected for .figma.ts / | ||
| # .figma.js templates (our parser is `html`) from 1.4.4 onward. Below that the | ||
| # flag is a no-op and an unparseable mapping is silently skipped — the exact | ||
| # green-but-stale failure this workflow guards against. | ||
| CODE_CONNECT_VERSION: '1.5.3' | ||
|
|
||
| jobs: | ||
| # PR gate: parse the *.figma.ts files against figma.config.json. Local only — | ||
| # no Figma access, no token — so it's safe to run on forks and validates that | ||
| # every mapping still compiles and resolves its imports/substitutions. | ||
| validate: | ||
| if: github.event_name == 'pull_request' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| - name: Set up Node.js (pinned npm) | ||
| uses: ./.github/workflows/actions/setup-node-with-pinned-npm | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| - name: Parse Code Connect files (validate, no publish) | ||
| shell: bash | ||
| # --exit-on-unreadable-files: fail instead of silently skipping a file the | ||
| # CLI can't parse — otherwise a broken mapping passes the gate green. | ||
| run: npx -y --package=@figma/code-connect@${CODE_CONNECT_VERSION} figma connect parse --exit-on-unreadable-files | ||
|
cursor[bot] marked this conversation as resolved.
|
||
|
|
||
| # Publish on merge to main or manual dispatch. Requires the FIGMA_ACCESS_TOKEN | ||
| # secret (a Figma personal access token with Code Connect write scope). | ||
| publish: | ||
| if: github.event_name != 'pull_request' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| - name: Set up Node.js (pinned npm) | ||
| uses: ./.github/workflows/actions/setup-node-with-pinned-npm | ||
| with: | ||
| node-version-file: '.nvmrc' | ||
| - name: Guard — require FIGMA_ACCESS_TOKEN | ||
| shell: bash | ||
| env: | ||
| FIGMA_ACCESS_TOKEN: ${{ secrets.FIGMA_ACCESS_TOKEN }} | ||
| run: | | ||
| if [ -z "${FIGMA_ACCESS_TOKEN}" ]; then | ||
| echo "::error::FIGMA_ACCESS_TOKEN secret is not set — cannot publish Code Connect. Add a Figma personal access token (Code Connect write scope) under repo Settings → Secrets and variables → Actions." | ||
| exit 1 | ||
| fi | ||
| - name: Publish Code Connect to Figma | ||
| shell: bash | ||
| env: | ||
| FIGMA_ACCESS_TOKEN: ${{ secrets.FIGMA_ACCESS_TOKEN }} | ||
| # --exit-on-unreadable-files: fail the publish rather than shipping a | ||
| # partial set and leaving stale Dev Mode snippets for the skipped files. | ||
| run: npx -y --package=@figma/code-connect@${CODE_CONNECT_VERSION} figma connect publish --exit-on-unreadable-files | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nonexistent CLI version pin
High Severity
CODE_CONNECT_VERSIONis pinned to@figma/code-connect@1.5.3, but that release is not on npm — latest is1.5.2. Bothnpxsteps resolve that package, so validate and publish fail on every run instead of parsing or publishing mappings.Reviewed by Cursor Bugbot for commit 1ca1f25. Configure here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
False positive —
1.5.3is live on npm.npm view @figma/code-connect@1.5.3resolves (published 2026-08-12, tarball present) anddist-tags.latest→1.5.3. The "latest is 1.5.2" appears to be a stale index; 1.5.2 shipped 2026-08-03, 1.5.3 nine days later. Keeping the pin at 1.5.3 (also comfortably ≥ the 1.4.4 required for--exit-on-unreadable-filesto apply to.figma.ts).