-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
110 additions
and
33 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Setup Node.js (v20) with Yarn v2 🚀 | ||
description: 'Set up Node.js version 20 and enable Yarn v2 using Corepack' | ||
|
||
inputs: | ||
node-version: | ||
description: 'The version of Node.js to set up.' | ||
required: true | ||
default: '20' | ||
|
||
outputs: | ||
node-version: | ||
description: 'The version of Node.js that was installed.' | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Set up Node.js v${{ inputs.node-version }} 💻 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
|
||
- name: Enable Yarn v2 ⚡️ | ||
run: | | ||
corepack enable | ||
yarn --version | ||
node --version | ||
shell: bash |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,102 @@ | ||
# Simple workflow for deploying static content to GitHub Pages | ||
name: Deploy static content to Pages | ||
name: 🚀 Test & Deploy Static Content to GitHub Pages | ||
|
||
on: | ||
# Runs on pushes targeting the default branch | ||
push: | ||
branches: ['main'] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
on: push | ||
|
||
# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
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 one concurrent deployment | ||
# Allow only one concurrent deployment at a time | ||
concurrency: | ||
group: 'pages' | ||
cancel-in-progress: true | ||
group: 'pages' # Group deployments by name for concurrency control | ||
cancel-in-progress: true # Cancel any in-progress deployments if a new one starts | ||
|
||
jobs: | ||
# Single deploy job since we're just deploying | ||
# 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 | ||
|
||
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 | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
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 | ||
- name: Checkout Repository 📥 | ||
uses: actions/checkout@v4 | ||
- run: corepack enable | ||
- name: Set up Node | ||
uses: actions/setup-node@v4 | ||
|
||
- name: Setup Node.js Environment ⚙️ | ||
uses: ./.github/actions/setup | ||
with: | ||
node-version: 20 | ||
cache: 'yarn' | ||
- name: Install dependencies | ||
run: yarn install | ||
- name: Build | ||
run: yarn build:demo | ||
- name: Setup Pages | ||
|
||
- 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 artifact | ||
|
||
- name: Upload Build Artifacts 📦 | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
# Upload dist folder | ||
path: './dist' | ||
- name: Deploy to GitHub Pages | ||
path: './dist' # Path to the build output directory | ||
|
||
- name: Deploy to GitHub Pages 🌐 | ||
id: deployment | ||
uses: actions/deploy-pages@v4 | ||
uses: actions/deploy-pages@v4 # Deploy the build to GitHub Pages |