diff --git a/.github/workflows/build-tokens.yaml b/.github/workflows/build-tokens.yaml
index 9315db50b8..85092bb6b6 100644
--- a/.github/workflows/build-tokens.yaml
+++ b/.github/workflows/build-tokens.yaml
@@ -3,7 +3,7 @@ on:
pull_request:
types: [opened, synchronize, edited, reopened]
paths:
- - 'packages/tokens'
+ - 'packages/tokens/**'
jobs:
build:
@@ -16,18 +16,58 @@ jobs:
- name: Setup
uses: ./.github/actions/setup-pnpm
- - name: Install tokens & dependencies
- run: pnpm --filter design-system-tokens... install
+ - name: Install dependencies
+ run: pnpm --filter ...design-system-tokens... install
- name: Build tokens & dependencies
- run: pnpm --filter design-system-tokens... build
+ run: pnpm --filter ...design-system-tokens... build
+
+ # TODOs:
+ # - Add changeset to the tokens package? (not sure if this should be done manually)
- name: Create Summary
id: summary
uses: actions/github-script@v7
with:
script: |
+ const fs = require('fs')
+ const path = require('path')
+
+ const inputfileNames = fs.readdirSync('packages/tokens/tokensstudio-generated')
+ const inputFiles = inputfileNames.map(fileName => ({
+ type: path.extname(fileName),
+ name: fileName,
+ content: fs.readFileSync(`packages/tokens/tokensstudio-generated/${fileName}`, 'utf8')
+ }))
+
+ const outputOrder = [
+ 'index.scss',
+ 'core.scss',
+ 'mode.scss',
+ 'device.scss',
+ 'channel.scss',
+ 'theme.scss',
+ 'components.scss',
+ ]
+ const outputFileNames = fs.readdirSync('packages/tokens/dist')
+ const outputFiles = outputFileNames.map(fileName => ({
+ type: path.extname(fileName),
+ name: fileName,
+ content: fs.readFileSync(`packages/tokens/dist/${fileName}`, 'utf8')
+ })).sort((a, b) => outputOrder.indexOf(a.name) === -1 ? Infinity : outputOrder.indexOf(a.name) - outputOrder.indexOf(b.name) === -1 ? Infinity : outputOrder.indexOf(b.name))
+
return `# Build Tokens
+ ## Input
+ ${inputFiles.map(({ type, name, content }) => `
+ ${name}
+ ${content}
+ `).join('\n')}
+
+ ## Output
+ ${outputFiles.map(({ type, name, content }) => `
+ ${name}
+ ${content}
+ `).join('\n')}
`
- name: Output Summary