Integrating with Github Actions
Pull tokens directly from Tokens Studio into your Github Actions to compliment your build pipeline.
Prerequisites
Example Workflow
5
6
Set up your Github action
# .github/workflows/pull-tokens.yml
name: "Sync & Build Design Tokens"
on:
workflow_dispatch:
jobs:
sync-and-build-tokens:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
# 1. Check out the repository code
- name: Checkout repository
uses: actions/checkout@v4
# 2. Set up Node.js
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"
# 3. Install project dependencies
- name: Install dependencies
run: npm install
# 4. Run the complete token sync process
- name: Sync, Build, and Format Tokens
run: npm run tokens:pull
env:
TOKENS_STUDIO_API_KEY: ${{ secrets.TOKENS_STUDIO_API_KEY }}
# 5. Commit files and create PR
- name: Commit and Create PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if ! git diff --quiet; then
echo "Changes detected. Creating a new branch and PR."
BRANCH_NAME="tokens/update-$(date +%s)"
git checkout -b $BRANCH_NAME
git add .
git commit -m "chore(tokens): Sync and build design tokens"
git push -u origin $BRANCH_NAME
gh pr create \
--title "🎨 Sync & Build Design Tokens" \
--body "This PR was automatically generated and contains the latest token updates from Tokens Studio." \
--base ${{ github.ref_name }} \
--head $BRANCH_NAME
else
echo "No changes to commit."
fi PreviousMigrating from Tokens Studio for Figma Plugin to the Tokens Studio PlatformNextTokens Studio for Figma Plugin
Last updated

