Skip to content

Update palette tokens #816

Update palette tokens

Update palette tokens #816

name: Update palette tokens
on:
schedule:
- cron: "0 8 * * *"
workflow_dispatch:
env:
new_files: false
jobs:
cron-update-tokens:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Node
uses: ./.github/actions/node
- name: Today date
run: echo "TODAY=$(date '+%Y-%m-%d')" >> $GITHUB_ENV
- name: Setup git identity
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
- name: Update palette
run: |
yarn tokens fetch:colors
yarn tokens build
yarn tokens jest -u
git add --all
if git diff-index --quiet HEAD; then
echo "No changes to tokens. Exiting."
echo "new_files=false" >> $GITHUB_ENV
else
git checkout -b feat/update-palette-tokens
git commit -m "feat(tokens): update palette"
git push origin feat/update-palette-tokens
echo "new_files=true" >> $GITHUB_ENV
fi
env:
FIGMA_TOKEN: ${{ secrets.FIGMA_TOKEN }}
- name: Create PR
uses: actions/github-script@v6
if: env.new_files == 'true'
with:
script: |
github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
head: 'feat/update-palette-tokens',
base: 'master',
title: 'feat(tokens): update palette tokens from figma',
body: `- Automatically generated PR on ${process.env.TODAY }.\n- Updates palette tokens from Figma`,
maintainer_can_modify: true,
});