fix(site): bundle css and remove css minification #6
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
# Build an Eleventy site and upload build artifacts. | |
name: Build | |
on: | |
push: | |
branches: master | |
paths: | |
- '**' | |
- '!.gitignore' | |
- '!*.md' | |
- '!LICENSE' | |
- '!.eslintignore' | |
- '!.eslintrc.yml' | |
- '!.github/**' | |
- '!.lycheeignore' | |
- '!.vscode/**' | |
- '!archive/**' | |
- '!scripts/**' | |
- '!ust/**' | |
# Allows this workflow to be called from other workflows. | |
workflow_call: | |
outputs: | |
artifact: | |
description: The artifact name of the uploaded site files. | |
value: ${{ jobs.build.outputs.artifact }} | |
# Allows you to run this workflow manually from the Actions tab. | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
outputs: | |
artifact: ${{ steps.upload.outputs.artifact }} | |
steps: | |
- name: Get Ref | |
id: get-ref | |
run: | | |
pr_ref="${{ github.event.pull_request.head.ref }}" | |
if [ -z "$pr_ref" ]; then | |
echo 'Using default ref.' | |
echo "ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT | |
else | |
echo 'Using PR ref.' | |
echo "ref=$pr_ref" >> $GITHUB_OUTPUT | |
fi | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all commit history. | |
ref: ${{ steps.get-ref.outputs.ref }} | |
- name: Sanity Check | |
run: | | |
echo '## ref' >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
echo "ref: ${{ github.ref }}" >> $GITHUB_STEP_SUMMARY | |
echo "ref_name: ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY | |
echo "ref_type: ${{ github.ref_type }}" >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
echo '## `git status`' >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
git status >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: npm | |
- name: Restore 11ty Cache | |
uses: actions/cache@v4 | |
with: | |
path: .cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-eleventy-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: ${{ runner.os }}-eleventy-${{ hashFiles('**/package-lock.json') }}- | |
- name: Restore npm Cache | |
id: cache-npm | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
- name: Install Dependencies | |
if: steps.cache-npm.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Build | |
run: | | |
echo "## Build Output" >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
npm run prod >> $GITHUB_STEP_SUMMARY | |
echo '```' >> $GITHUB_STEP_SUMMARY | |
- id: upload | |
run: echo 'artifact=site-${{ steps.get-ref.outputs.ref }}' | tr '/' '-' >> $GITHUB_OUTPUT | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.upload.outputs.artifact }} | |
path: _site/ | |
retention-days: 1 |