chore(build): build demo as a separate process #41 #21
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: π Test & Deploy Static Content to GitHub Pages | |
on: push | |
# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages | |
permissions: | |
contents: read # Read access to repository contents | |
pages: write # Write access for deployment to GitHub Pages | |
id-token: write # Allow GitHub to issue an ID token for authentication | |
# Allow only one concurrent deployment at a time | |
concurrency: | |
group: pages # Group deployments by name for concurrency control | |
cancel-in-progress: true # Cancel any in-progress deployments if a new one starts | |
jobs: | |
# Setup environment and dependencies | |
setup: | |
name: π οΈ Setup Development Environment | |
runs-on: ubuntu-latest | |
outputs: | |
node-modules-path: ${{ steps.cache-dependencies.outputs.cache-hit }} | |
steps: | |
- name: Checkout Repository π₯ | |
uses: actions/checkout@v4 | |
- name: Cache Dependencies π¦ | |
uses: actions/cache@v4 | |
id: cache-dependencies | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Setup Node.js Environment βοΈ | |
uses: ./.github/actions/setup | |
with: | |
node-version: 20 | |
- name: Install Dependencies π οΈ | |
run: yarn install --immutable | |
if: steps.cache-dependencies.outputs.cache-hit != 'true' # Only install if cache miss | |
- name: Run Linter π§βπ» | |
run: yarn lint | |
tests: | |
name: π Execute Unit Tests | |
needs: setup | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository π₯ | |
uses: actions/checkout@v4 | |
- name: Setup Node.js Environment βοΈ | |
uses: ./.github/actions/setup | |
with: | |
node-version: 20 | |
- name: Install Dependencies π οΈ | |
run: yarn install --immutable | |
- name: Run Tests π§ͺ | |
run: yarn test | |
deploy: | |
name: π Deploy to GitHub Pages | |
needs: [setup, tests] | |
if: github.ref == 'refs/heads/main' # Only deploy from the main branch | |
environment: | |
name: github-pages # Set deployment environment to GitHub Pages | |
url: ${{ steps.deployment.outputs.page_url }} # Output page URL | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository π₯ | |
uses: actions/checkout@v4 | |
- name: Setup Node.js Environment βοΈ | |
uses: ./.github/actions/setup | |
with: | |
node-version: 20 | |
- name: Install Dependencies π οΈ | |
run: yarn install --immutable | |
- name: Build Static Content ποΈ | |
run: yarn build:demo # Build the static site with Vite | |
- name: Setup GitHub Pages βοΈ | |
uses: actions/configure-pages@v4 | |
- name: Upload Build Artifacts π¦ | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./demo # Path to the build output directory | |
- name: Deploy to GitHub Pages π | |
id: deployment | |
uses: actions/deploy-pages@v4 # Deploy the build to GitHub Pages |