Skip to content

Import Figma icons

Import Figma icons #48

name: Import Figma icons
on:
workflow_dispatch:
schedule:
- cron: "0 6 * * *" # run daily at 6 am
jobs:
import:
name: Import Figma icons
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .node-version
cache: pnpm
- name: 📦 Install dependencies
run: pnpm install
- name: 🛠️ Build Figma utils
run: pnpm run build
working-directory: packages/figma-utils
# delete all icons before importing them so no longer existing or renamed icons are removed
- name: Clear icons
run: rm -rfv src/assets/*
working-directory: packages/icons
- name: Import icons
run: |
pnpm run @sit-onyx/figma-utils import-icons -k "${{ vars.FIGMA_FILE_KEY_ICONS }}" -t "${{ secrets.FIGMA_TOKEN }}" -p "${{ vars.FIGMA_ICON_PAGE_ID }}" -d "../icons/src/assets" -m "../icons/src/metadata.json"
working-directory: packages/figma-utils
- name: Generate changeset
run: |
git add .
pnpm run generate:changeset
working-directory: packages/icons
# needed to prevent creating empty PR when nothing but the formatting changed
- name: Format with prettier
run: pnpm prettier --write src/metadata.json
working-directory: packages/icons
- name: Create pull request
uses: peter-evans/create-pull-request@v7
with:
commit-message: "feat: update Figma icons"
title: "feat: update Figma icons"
body: |
This is an auto-generated pull request.
All icons have been imported from the [Figma file](https://www.figma.com/design/${{ vars.FIGMA_FILE_KEY_ICONS }}?node-id=${{ vars.FIGMA_ICON_PAGE_ID }}).
branch-suffix: short-commit-hash # needed to not override other pull requests created via workflows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_NAME: ${{ github.ref_name }}