Skip to content

Commit

Permalink
feat(workflows): add a build-tokens workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverschuerch committed Jul 12, 2024
1 parent 099ac7a commit c14a8d4
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
41 changes: 39 additions & 2 deletions .github/workflows/build-tokens.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
types: [opened, synchronize, edited, reopened]
paths:
- 'packages/tokens'
- 'packages/tokens/**'

jobs:
build:
Expand All @@ -16,7 +16,7 @@ jobs:
- name: Setup
uses: ./.github/actions/setup-pnpm

- name: Install tokens & dependencies
- name: Install dependencies
run: pnpm --filter design-system-tokens... install

- name: Build tokens & dependencies
Expand All @@ -27,7 +27,44 @@ jobs:
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 ? 1000 : outputOrder.indexOf(a.name)) - (outputOrder.indexOf(b.name) === -1 ? 1000 : outputOrder.indexOf(b.name)))
return `# Build Tokens
## Input
${inputFiles.map(({ type, name, content }) => `<details>
<summary><code>${name}</code></summary>
<pre lang="${type}">${content}</pre>
</details>`).join('\n')}
## Output
${outputFiles.map(({ type, name, content }) => `<details>
<summary><code>${name}</code></summary>
<pre lang="${type}">${content}</pre>
</details>`).join('\n')}
`
- name: Output Summary
Expand Down
3 changes: 1 addition & 2 deletions packages/tokens/tokensstudio-generated/tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -1377,8 +1377,7 @@
"Theme/Default",
"Theme/Cargo",
"Components/All",
"core/core",
"Test"
"core/core"
]
}
}

0 comments on commit c14a8d4

Please sign in to comment.