Skip to content

Instantly share code, notes, and snippets.

@leex279
Last active January 11, 2025 18:40
Show Gist options
  • Select an option

  • Save leex279/6b694b7217a4c5a04907b6f1aa1bd3df to your computer and use it in GitHub Desktop.

Select an option

Save leex279/6b694b7217a4c5a04907b6f1aa1bd3df to your computer and use it in GitHub Desktop.
Github pages Deployment Workflow (nodejs webapp)
# Sample workflow for building and deploying a site to GitHub Pages
name: Deploy Site with 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:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
# Checkout the repository
- name: Checkout
uses: actions/checkout@v4
# Set up Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 22 # Use the Node.js version required for your project
# Install dependencies and build the project
- name: Install dependencies and build
run: |
npm install
npm run build
# Upload the dist folder as an artifact
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist # Path to the built files
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
# Deploy the dist folder to GitHub Pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment