Skip to content

Test local builds

Test local builds #13

Workflow file for this run

# Workflow for building and deploying a demo site to GitHub Pages
name: Deploy static demo files to Pages
on: push
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these deployments to complete.
concurrency:
group: 'pages'
cancel-in-progress: false
jobs:
build:
name: Build the project
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22.5.1'
cache: 'npm'
- name: Try to restore node_modules folder from cache
id: cache-node-modules
uses: actions/cache@v4
with:
path: ./node_modules
key: npm-${{ hashFiles('./package-lock.json') }}
- name: Otherwise install npm dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
- name: Update package.json version if necessary
if: startsWith(github.ref, 'refs/tags/v')
run: |
TAG_VERSION=${GITHUB_REF#refs/tags/v}
PACKAGE_VERSION=$(node -p "require('./package.json').version")
if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then
npm version --allow-same-version --no-git-tag-version $TAG_VERSION
echo "::warning::Tag version ($TAG_VERSION) did not match package.json version ($PACKAGE_VERSION). Updated package.json to $TAG_VERSION."
else
echo "::info::Tag version ($TAG_VERSION) matches package.json version ($PACKAGE_VERSION)."
fi
- name: Build the files!
run: npm run build
env:
NODE_OPTIONS: '--max-old-space-size=8192'
- name: Download Pages artifact
uses: dawidd6/action-download-artifact@v6
with:
name: github-pages
path: pages
continue-on-error: true
- name: Rename dist folder, delete existing demo
run: |
BRANCH_OR_TAG_NAME=${GITHUB_REF#refs/heads/}
BRANCH_OR_TAG_NAME=${BRANCH_OR_TAG_NAME#refs/tags/}
mkdir -p pages
cd pages
if [ -f artifact.tar ]; then
tar -xvf artifact.tar;
rm artifact.tar;
else
echo "artifact.tar not found";
fi
rm -rf $BRANCH_OR_TAG_NAME
mv ../dist $BRANCH_OR_TAG_NAME
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'pages/'
retention-days: 30
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4