-
Notifications
You must be signed in to change notification settings - Fork 13
78 lines (65 loc) · 2.88 KB
/
build-figma-tokens.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Generate scss vars from figma tokens
on:
push:
branches:
- issue-995-design-tokens
paths:
- 'figma-tokens/input/**'
jobs:
build_tokens:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
# Configuring Node.js Environment
- name: Setup Node.js environment
uses: actions/setup-node@v2.4.0
# Setting dependencies
- name: Install dependencies
run: npm ci
# Token conversion using token-transformer
- name: Transform Figma tokens
run: npx token-transformer figma-tokens/input/tokens.json figma-tokens/transformed-tokens/tokens-transformed.json
# Run script for Style Dictionary, convert JSON to SCSS
- name: Build Figma tokens to SCSS
run: npm run build-tokens
# Create or update the `update-figma-tokens` branch
- name: Create or update branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git fetch origin
# Add and commit changes before creating or updating a branch
# git add figma-tokens/transformed-tokens/tokens-transformed.json
git add stories/assets/scss/figma-scss/_figma-variables.scss
git commit -m "Save changes before switching branch" || echo "No changes to commit"
# # Check if remote branch exists
# if git ls-remote --exit-code --heads origin update-figma-tokens; then
# git checkout update-figma-tokens
# git pull --rebase origin update-figma-tokens
# else
# git checkout -b update-figma-tokens
# fi
# git add stories/assets/scss/figma-scss/_figma-variables.scss
# git commit -m "Save changes in new branch" || echo "No changes to commit"
# Push changes to `update-figma-tokens` branch
- name: Push changes
run: |
git push origin ${{ github.ref_name }} || echo "No changes to push"
# # Automatically add and commit all changes including SCSS
# - name: Auto commit updated tokens and SCSS
# uses: stefanzweifel/git-auto-commit-action@v4
# with:
# commit_message: "build: update SCSS variables and tokens"
# file_pattern: stories/assets/scss/figma-scss/_figma-variables.scss
# branch: update-figma-tokens # Commit to the new branch
# Automatic pull request
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref_name }}
base: develop # Target branch for the PR
commit-message: "build: update SCSS variables from Figma tokens"
title: "Update SCSS variables from Figma tokens"
body: "This PR updates SCSS variables based on the latest Figma tokens."