Skip to content

Update design tokens from Figma #50

Update design tokens from Figma

Update design tokens from Figma #50

Workflow file for this run

name: update-design-tokens
run-name: Update design tokens from Figma
on:
workflow_dispatch:
inputs:
organization:
type: choice
description: Which org did you make changes for?
required: false
default: all
options:
- all
- atb
- fram
- nfk
- troms
- innlandet
- vkt
- farte
jobs:
update-variables:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- run: git checkout -b bot-design-tokens-$(date +%Y%m%d%H%M%S)
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Fetch variables from Figma
env:
FIGMA_REST_API_KEY: ${{ secrets.FIGMA_REST_API_KEY }}
FIGMA_VARIABLES_URL: ${{ vars.FIGMA_VARIABLES_URL }}
run: |
yarn install --immutable
yarn fetch-variables
yarn build-all
- name: Commit new design tokens
run: |
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
if [[ "${{ inputs.organization }}" == "all" || -z "${{ inputs.organization }}" ]]; then
# Stage all changes if no org was specified
git add **/src/generated/themes/*
else
# Stage only files related to the selected organization
git add **/src/generated/themes/${{ inputs.organization }}-theme/*
fi
git commit -m "style: Updated design tokens"
git push origin "${CURRENT_BRANCH}"
- name: Create PR for changes
run: |
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "${{ inputs.organization }}" == "all" || -z "${{ inputs.organization }}" ]]; then
ORG_SUFFIX=""
else
ORG_SUFFIX=" for \`${{ inputs.organization }}\`"
fi
gh pr create --title "[BOT] Updated design tokens${ORG_SUFFIX}" --body "Design tokens ${ORG_SUFFIX} were automatically fetched from Figma and parsed into design tokens. The changes can be reviewed in the `Files changed` tab." --head "${CURRENT_BRANCH}" --base main --assignee "${{ github.actor }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}