Skip to content

Instantly share code, notes, and snippets.

@beveradb
Created July 3, 2024 19:31
Show Gist options
  • Save beveradb/92f9a7a56f761eaf31f3396e5e867f4f to your computer and use it in GitHub Desktop.
Save beveradb/92f9a7a56f761eaf31f3396e5e867f4f to your computer and use it in GitHub Desktop.
Github Actions workflow to deploy a Create React App to Github Pages
name: Build and Deploy to GitHub Pages
on:
push:
branches:
- main
permissions:
contents: read
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Github Pages
id: pages
uses: actions/configure-pages@v5
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Install dependencies
run: npm install
- name: Build
run: CI=false npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./build
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- 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