Skip to content

Version Packages (#828) #1013

Version Packages (#828)

Version Packages (#828) #1013

Workflow file for this run

# Deploy both Vue and HTML Storybooks to Chromatic
name: 'Storybook'
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'apps/vue-storybook/**'
- 'packages/common/**'
- 'packages/vue/**'
pull_request:
branches-ignore:
- 'changeset-release/**'
paths:
- 'apps/vue-storybook/**'
- 'packages/common/src/**'
- 'packages/common/*.js'
- 'packages/common/*.ts'
- 'packages/vue/src/**'
jobs:
publish_vue:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Find Latest Licensed Font Run ID
id: find_run
uses: actions/github-script@v8
with:
github-token: ${{ secrets.EXPLORER_1_FONTS_TOKEN }}
script: |
const { owner, repo } = context.repo;
// Query the private repo for the latest successful workflow run
const runs = await github.rest.actions.listWorkflowRuns({
owner: 'nasa-jpl',
repo: 'explorer-1-fonts',
workflow_id: 'generate-css-artifact.yml',
branch: 'main',
status: 'success',
per_page: 1
});
const runId = runs.data.workflow_runs[0]?.id;
if (!runId) {
core.setFailed("Could not find a successful run for the licensed font workflow.");
return;
}
console.log(`Found Run ID: ${runId}`);
core.setOutput('run_id', runId);
- name: Download Licensed Font Artifact
uses: actions/download-artifact@v7
with:
name: explorer-1-licensed-fonts
repository: nasa-jpl/explorer-1-fonts
path: ./packages/common-storybook/src/
run-id: ${{ steps.find_run.outputs.run_id }}
github-token: ${{ secrets.EXPLORER_1_FONTS_TOKEN }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Set up Node ⬢
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install dependencies 🧱
run: pnpm i
- name: Generate Font Data and Flag Modules (Shell Injection)
run: |
# Ensure the primary shell script is executable
chmod +x packages/common-storybook/src/scripts/inject-fonts-shell.sh
# Execute the shell script, passing all necessary paths as arguments
./packages/common-storybook/src/scripts/inject-fonts-shell.sh \
./packages/common-storybook/src \
./packages/common-storybook/src/licensed-fonts-base64.css \
./packages/common-storybook/src/fonts-data.js \
./packages/common-storybook/src/font-flag.js \
- name: Build Storybook
run: make vue-storybook-build
env:
VITE_CHROMATIC_BUILD: true
- uses: chromaui/action@latest
# Options required for Chromatic's GitHub Action
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
storybookBaseDir: 'apps/vue-storybook'
storybookBuildDir: 'apps/vue-storybook/storybook_compiled'
autoAcceptChanges: 'main'
exitZeroOnChanges: true
exitOnceUploaded: true
onlyChanged: true
publish_html:
needs: [publish_vue]
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Find Latest Licensed Font Run ID
id: find_run
uses: actions/github-script@v8
with:
github-token: ${{ secrets.EXPLORER_1_FONTS_TOKEN }}
script: |
const { owner, repo } = context.repo;
// Query the private repo for the latest successful workflow run
const runs = await github.rest.actions.listWorkflowRuns({
owner: 'nasa-jpl',
repo: 'explorer-1-fonts',
workflow_id: 'generate-css-artifact.yml',
branch: 'main',
status: 'success',
per_page: 1
});
const runId = runs.data.workflow_runs[0]?.id;
if (!runId) {
core.setFailed("Could not find a successful run for the licensed font workflow.");
return;
}
console.log(`Found Run ID: ${runId}`);
core.setOutput('run_id', runId);
- name: Download Licensed Font Artifact
uses: actions/download-artifact@v7
with:
name: explorer-1-licensed-fonts
repository: nasa-jpl/explorer-1-fonts
path: ./packages/common-storybook/src/
run-id: ${{ steps.find_run.outputs.run_id }}
github-token: ${{ secrets.EXPLORER_1_FONTS_TOKEN }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Set up Node ⬢
uses: actions/setup-node@v6
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install dependencies 🧱
run: pnpm i
- name: Generate Font Data and Flag Modules (Shell Injection)
run: |
# Ensure the primary shell script is executable
chmod +x packages/common-storybook/src/scripts/inject-fonts-shell.sh
# Execute the shell script, passing all necessary paths as arguments
./packages/common-storybook/src/scripts/inject-fonts-shell.sh \
./packages/common-storybook/src \
./packages/common-storybook/src/licensed-fonts-base64.css \
./packages/common-storybook/src/fonts-data.js \
./packages/common-storybook/src/font-flag.js \
- name: Build HTML Storybook
run: make html-storybook-build
env:
VITE_CHROMATIC_BUILD: true
- uses: chromaui/action@latest
# Options required for Chromatic's GitHub Action
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN_HTML }}
token: ${{ secrets.GITHUB_TOKEN }}
storybookBaseDir: 'apps/html-storybook'
storybookBuildDir: 'apps/html-storybook/storybook_compiled'
autoAcceptChanges: 'main'
exitZeroOnChanges: true
exitOnceUploaded: true
onlyChanged: true