Upgrade deps (#57) #125
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
# Workflow to build and test node.js app with install, build, and test scripts. | |
# The workflow also expects that the app will have a github pages built using build | |
# that will live under /docs, and so also automatically adds and commits /docs | |
# whenever "release:" prefixed commits are made. | |
name: main | |
# Any event listed can trigger build/test; only push triggers docs build and new tag | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
# Manual run from GitHub UI | |
workflow_dispatch: | |
# Wednesdays at 0400 | |
# schedule: | |
# - cron: '0 4 * * 3' | |
permissions: | |
pages: write | |
contents: write | |
jobs: | |
build-and-test: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
environment: build-fonts | |
strategy: | |
matrix: | |
node-version: [lts/*] | |
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | |
env: | |
# Suppresses annoying warning https://github.com/cypress-io/cypress/issues/15679 | |
TERM: xterm | |
# Suppress Cypress installation progress messages | |
CI: 1 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Install | |
run: npm ci | |
- name: Build | |
run: npm run build --if-present | |
- name: Install Cypress | |
uses: cypress-io/github-action@v6 | |
with: | |
runTests: false | |
- name: Test using Cypress - E2E | |
uses: cypress-io/github-action@v6 | |
with: | |
# Test against the build we just created | |
start: npm run preview | |
config: baseUrl=http://localhost:4173/react-fontpicker | |
working-directory: packages/fontpicker | |
install: false | |
- name: Test using Cypress - Component | |
uses: cypress-io/github-action@v6 | |
with: | |
component: true | |
working-directory: packages/fontpicker | |
install: false | |
- name: Test | |
run: npm run test | |
- name: Add GOOGLE_API_KEY | |
run: echo "${{secrets.GOOGLE_API_KEY}}" > packages/fontpicker/GOOGLE_API_KEY | |
- name: Restore font-cache | |
id: cache-font-restore | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
packages/fontpicker/font-cache | |
key: font-cache-${{ hashFiles('packages/fontpicker/scripts/75-google-fonts.txt') }} | |
- name: Build fontpicker-lite package | |
run: bash packages/fontpicker-lite/build-lite.sh | |
- name: Save font-cache | |
id: cache-font-save | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
packages/fontpicker/font-cache | |
key: ${{ steps.cache-font-restore.outputs.cache-primary-key }} | |
- name: Test fontpicker-lite package | |
run: bash packages/fontpicker-lite/test-lite.sh | |
# For push events only, rebuild docs page and create a tag. | |
# Ideally this would be in a separate job, but jobs execute on different runners which means | |
# some duplication with above. | |
- name: Test is release | |
if: startsWith(github.event.head_commit.message, 'release:') && github.event_name == 'push' | |
id: isRelease | |
run: | | |
echo "value=true" >> $GITHUB_OUTPUT | |
- name: Get release version string | |
if: steps.isRelease.outputs.value | |
id: getVersion | |
env: | |
MESSAGE: ${{ github.event.head_commit.message }} | |
run: | | |
VALUE=$(echo "${MESSAGE}" | sed 's/release://' | sed 's/[[:space:]]*//g') | |
echo "value=${VALUE}" >> $GITHUB_OUTPUT | |
- name: Commit /docs | |
if: steps.isRelease.outputs.value | |
# EndBug/add-and-commit@v9.1.1 | |
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 | |
with: | |
default_author: github_actions | |
add: 'packages/fontpicker/docs' | |
message: "docs: rebuild for release ${{ steps.getVersion.outputs.value }}" | |
- name: Create tag | |
if: steps.isRelease.outputs.value | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: "refs/tags/${{ steps.getVersion.outputs.value }}", | |
sha: context.sha | |
}) |