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 6cc3c32
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 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,19 +16,46 @@ 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)
# - Build all packages which are dependant on the tokens --filter ...design-system-tokens
# (styles and components for sure, maybe more)

- name: Create Summary
id: summary
uses: actions/github-script@v7
with:
script: |
return `# Build Tokens
`
const fs = require('fs')
const inputfileNames = fs.readdirSync('packages/tokens/tokensstudio-generated')
const inputFiles = inputfileNames.map(fileName => ({ name: fileName, content: fs.readFileSync(`packages/tokens/tokensstudio-generated/${fileName}`, 'utf8') }))
const outputFileNames = fs.readdirSync('packages/tokens/dist')
const outputFiles = outputFileNames.map(fileName => ({ name: fileName, content: fs.readFileSync(`packages/tokens/dist/${fileName}`, 'utf8') }))
return `# Build Tokens
## Input
${inputFiles.map(({ name, content }) => `<details>
<summary><code>${name}</code></summary>
\`\`\`json
${content}
\`\`\`
</details>`).join('\n')}
## Output
${outputFiles.map(({ name, content }) => `<details>
<summary><code>${name}</code></summary>
\`\`\`json
${content}
\`\`\`
</details>`).join('\n')}
`
- name: Output Summary
run: echo -e ${{ steps.summary.outputs.result }} >> $GITHUB_STEP_SUMMARY

0 comments on commit 6cc3c32

Please sign in to comment.