Skip to content

Using official GP action #8

Using official GP action

Using official GP action #8

Workflow file for this run

# https://dev.to/github/how-to-deploy-a-static-site-in-any-framework-of-your-choice-github-pages-neh
name: Deploy to GitHub Pages
on:
# Trigger the workflow every time you push to the `main` branch
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab on GitHub.
workflow_dispatch:
pull_request:
branches: [ main ]
# Allow this job to clone the repo and create a page deployment
permissions:
contents: read
pages: write
id-token: write
jobs:
test-and-build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
- name: Run tests
uses: cypress-io/github-action@v6
with:
start: npm run preview
wait-on: 'http://localhost:5173'
browser: chrome
config: baseUrl=http://localhost:5173
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./dist
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: test-and-build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1