feat(workflows): add a build-tokens workflow #20
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Tokens | |
on: | |
pull_request: | |
types: [opened, synchronize, edited, reopened] | |
paths: | |
- 'packages/tokens/**' | |
jobs: | |
build: | |
name: Build Tokens | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup | |
uses: ./.github/actions/setup-pnpm | |
- name: Install dependencies | |
run: pnpm --filter ...design-system-tokens... install | |
- name: Build tokens & dependencies | |
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: | | |
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\n' + content + '\n```'} | |
</details>`).join('\n')} | |
## Output | |
${outputFiles.map(({ name, content }) => `<details> | |
<summary><code>${name}</code></summary> | |
${'```json\n' + content + '\n```'} | |
</details>`).join('\n')} | |
` | |
- name: Output Summary | |
run: echo -e ${{ steps.summary.outputs.result }} >> $GITHUB_STEP_SUMMARY |