Skip to content

Commit 34660b0

Browse files
authored
fix: update workflow to auth with OIDC (#1756)
* fix: update workflow to auth with OIDC * chore: finalize the workflow and contribution doc
1 parent bf40864 commit 34660b0

File tree

4 files changed

+67
-58
lines changed

4 files changed

+67
-58
lines changed

.changeset/busy-clocks-bet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@launchpad-ui/icons": patch
3+
---
4+
5+
fix: update sync script to reference the correct file

.github/workflows/sync-icons.yml

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ name: Sync icons
33
on:
44
workflow_dispatch:
55

6-
permissions:
7-
contents: write
8-
pull-requests: write
9-
106
jobs:
117
sync-icons:
8+
if: github.repository == 'launchdarkly/launchpad-ui'
129
runs-on: ubuntu-latest
10+
permissions:
11+
id-token: write
12+
contents: write
13+
pull-requests: write
1314
steps:
1415
- name: Get Tokens
1516
uses: launchdarkly/gh-actions/actions/[email protected]
1617
with:
1718
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
1819
ssm_parameter_pairs: |
19-
/production/common/launchpad-ui/figma-file-key = FIGMA_FILE_KEY,
2020
/production/common/launchpad-ui/figma-access-token = FIGMA_ACCESS_TOKEN
2121
2222
- name: Checkout
@@ -26,71 +26,61 @@ jobs:
2626

2727
- name: Setup PNPM
2828
uses: pnpm/action-setup@v4
29-
with:
30-
version: 9
31-
run_install: false
3229

3330
- name: Setup Node
3431
uses: actions/setup-node@v4
3532
with:
36-
node-version: 20
33+
node-version: 22
3734
cache: pnpm
3835

3936
- name: Install dependencies
4037
run: pnpm install
4138

4239
- name: Sync Icons
43-
run: pnpm nx @launchpad-ui/icons:sync
44-
env:
45-
CI: true
46-
NX_NO_DAEMON: true
40+
run: pnpm nx run @launchpad-ui/icons:sync
4741

4842
- name: Connect Icons
49-
run: pnpm nx @launchpad-ui/icons:connect
50-
env:
51-
CI: true
52-
NX_NO_DAEMON: true
43+
run: pnpm nx run @launchpad-ui/icons:connect
5344

5445
- name: Detect changes
5546
id: changes
5647
run: |
57-
git status --short
58-
if git diff --quiet && git diff --cached --quiet; then
59-
echo "changed=false" >> "$GITHUB_OUTPUT"
60-
echo "No changes detected."
48+
if [[ -n "$(git status --porcelain)" ]]; then
49+
echo "changed=true" >> $GITHUB_OUTPUT
6150
else
62-
echo "changed=true" >> "$GITHUB_OUTPUT"
63-
echo "Changes detected."
51+
echo "changed=false" >> $GITHUB_OUTPUT
6452
fi
6553
66-
- name: Add changeset
54+
- name: Create changeset
55+
id: create-changeset
6756
if: steps.changes.outputs.changed == 'true'
6857
run: npx changeset add --empty
69-
env:
70-
CI: true
71-
NX_NO_DAEMON: true
58+
59+
- name: Write to created changeset file
60+
if: steps.changes.outputs.changed == 'true'
61+
run: |
62+
CHANGESET_FILE=$(ls -t .changeset/*.md | head -n1)
63+
CHANGE_TYPE="---\n\"@launchpad-ui/icons\": patch\n---"
64+
CHANGE_SUMMARY="feat(icons): sync and connect icons with figma library\n${{ env.CHANGESET_SUMMARY }}"
65+
echo -e "$CHANGE_TYPE\n\n$CHANGE_SUMMARY" > $CHANGESET_FILE
7266
7367
- name: Create Pull Request
7468
if: steps.changes.outputs.changed == 'true'
75-
id: cpr
7669
uses: peter-evans/create-pull-request@v6
7770
with:
78-
branch: ci/sync-icons
71+
branch: ci/feat/sync-icons
7972
delete-branch: true
80-
commit-message: "feat(icons): sync & connect icons"
81-
title: "feat(icons): sync & connect icons"
73+
commit-message: "feat(icons): sync and connect icons with figma library"
74+
title: "feat(icons): sync and connect icons with figma library"
8275
body: |
83-
Automated icon sync & connect run.
84-
Commands executed:
85-
- pnpm nx @launchpad-ui/icons:sync
86-
- pnpm nx @launchpad-ui/icons:connect
87-
88-
Diff:
89-
${{ env.DIFF_BODY }}
76+
## Summary
77+
This PR is an automated icon sync with LaunchPad Figma library. If you resync while this PR is open, the updated changes will be added to this same PR.
78+
${{ env.CHANGESET_SUMMARY }}
9079
labels: |
9180
icons
81+
ci
9282
assignees: ${{ github.actor }}
9383

94-
- name: No-op (no changes)
84+
- name: No-op (when no changes to icons)
9585
if: steps.changes.outputs.changed != 'true'
9686
run: echo "No changes detected, skipping changeset and PR creation."

CONTRIBUTING.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,18 +183,18 @@ $ pnpm test
183183

184184
### Adding Icons to LaunchPad
185185

186-
_Do not add icons manually. LaunchPad icons are managed in Figma and synced to the `@launchpad-ui/icons` package via a script._
187-
188-
To add a new icon to LaunchPad:
189-
190-
- Create a branch in the LaunchPad Figma library and add your icon to the /Icons page.
191-
- Make sure your new icon is reviewed by design. You can always ping `@uxteam` in #ask-launchpad-design-system if you need help making your icon or to get a review.
192-
- Merge the icon to the LaunchPad Figma library
193-
- Run the `sync-icons` GitHub action. This action does the following:
194-
- Runs `pnpm nx run @launchpad-ui/icons:sync` to build the icons from Figma
195-
- Runs `pnpm nx run @launchpad-ui/icons:connect` to update the icons [Figma Code Connect](https://github.com/figma/code-connect/blob/main/cli/scripts/README.md) file.
196-
- Opens a pull request for you
197-
- Open the `Components/Icons` page on the PR deployed Chromatic storybook to ensure your icon was generated properly.
186+
_Do not add icons manually to launchpad-ui. Icons are managed in Figma and synced to the `@launchpad-ui/icons` package via a script._
187+
188+
#### First, add your icon to the Figma library
189+
190+
1. Create a branch in the LaunchPad Figma library and add your icon to the [Icons](https://www.figma.com/design/98HKKXL2dTle29ikJ3tzk7/%F0%9F%9A%80-LaunchPad?m=auto&node-id=1-1483&t=YGNnNEonY474hKwo-1) page.
191+
1. Make sure your new icon is reviewed by Design. You can always ping the `@uxteam` in #ask-launchpad-design-system if you need help making your icon or to get a review.
192+
1. Merge the icon to the LaunchPad Figma library
193+
194+
#### Then, sync `@launchpad-ui/icons` package with Figma
195+
196+
1. Trigger the `sync-icons` workflow by going to [the actions tab](https://github.com/launchdarkly/launchpad-ui/actions/workflows/sync-icons.yml) and clicking "Run workflow". This action will generate a PR with your new icon.
197+
1. [Open your PR](https://github.com/launchdarkly/launchpad-ui/pulls?q=is%3Apr+is%3Aopen+label%3Aicons). Make sure your icons look correct by opening the Chromatic build preview for your PR. Reviewers will be auto assigned.
198198

199199

200200
## Styleguides

packages/icons/scripts/figma-sync.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ try {
3131

3232
// Figma API constants
3333
const FIGMA_ACCESS_TOKEN = process.env.FIGMA_ACCESS_TOKEN;
34-
const FIGMA_FILE_KEY = process.env.FIGMA_FILE_KEY as string;
35-
const FIGMA_NODE_ID = process.env.FIGMA_NODE_ID || '1:1483';
34+
const FIGMA_FILE_KEY = '98HKKXL2dTle29ikJ3tzk7';
35+
const FIGMA_NODE_ID = '1:1483';
3636
const DRY_RUN = process.env.DRY_RUN === '1';
3737

3838
if (!FIGMA_ACCESS_TOKEN || !FIGMA_FILE_KEY) {
@@ -44,6 +44,8 @@ const ROOT = path.resolve(process.cwd());
4444
const SPRITE_PATH = path.join(ROOT, 'src/img/sprite.svg');
4545
const TYPES_PATH = path.join(ROOT, 'src/types.ts');
4646

47+
const ENV_FILE = process.env.GITHUB_ENV || '';
48+
4749
const AUTO_GENERATED_BANNER =
4850
'This file is auto-generated by scripts/figma-icons.ts. Do not edit manually.';
4951

@@ -390,19 +392,31 @@ async function main(): Promise<void> {
390392
return;
391393
}
392394

393-
// 4) Diff output (kept from original for visibility)
395+
// 4) Diff output (kept from original for visibility) and set a change summary
396+
let changesetSummary = '';
394397
if (existingIcons.length) {
395398
const upcomingNames = normalized.map((n) => n.name);
396399
const existingSet = new Set(existingIcons);
397400
const upcomingSet = new Set(upcomingNames);
398401
const added = upcomingNames.filter((n) => !existingSet.has(n));
399402
const removed = existingIcons.filter((n) => !upcomingSet.has(n));
400-
if (added.length) log('added', `🆕 New icon(s) to add: ${added.join(', ')}`);
401-
if (removed.length)
402-
log('removed', `✂️ Icon(s) no longer present and will be removed: ${removed.join(', ')}`);
403+
404+
if (added.length) {
405+
const addedSummary = `New icons: ${added.join(', ')}`;
406+
changesetSummary += `\n${addedSummary}`;
407+
log('added', `🆕 ${addedSummary}`);
408+
}
409+
410+
if (removed.length) {
411+
const removedSummary = `Removed icons: ${removed.join(', ')}`;
412+
changesetSummary += `\n${removedSummary}`;
413+
log('removed', `✂️ ${removedSummary}`);
414+
}
403415
} else {
404-
log('diff', '🎁 No existing types.ts or no icons parsed; treating all as new.');
416+
changesetSummary += '\ninitial sync of icons from Figma';
417+
log('diff', '🎁 No existing icons. Treating all as new.');
405418
}
419+
fs.appendFileSync(ENV_FILE, `CHANGESET_SUMMARY<<EOF\n${changesetSummary}\nEOF\n`);
406420

407421
// 5) Resolve image URLs in bounded parallel batches (NEW)
408422
const idToUrl = await fetchSvgUrls(normalized);

0 commit comments

Comments
 (0)