Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deploy workflow #133

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 55 additions & 15 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
# Build and deploy a Gatsby site to GitHub Pages
name: Gatsby Build & Deploy

on:
pull_request:
workflow_dispatch:
workflow_dispatch:
push:
branches:
- main
branches: [$default-branch]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pages
cancel-in-progress: false

defaults:
run:
shell: bash

jobs:
deploy:
build:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- name: Checkout repository
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
Expand All @@ -21,18 +35,44 @@ jobs:
node-version: 22
cache: yarn

- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
with:
# Automatically inject pathPrefix in your Gatsby configuration file.
static_site_generator: gatsby

- name: Restore cache
uses: actions/cache@v4
with:
path: |
public
.cache
key: ${{ runner.os }}-gatsby-build-${{ hashFiles('public') }}
restore-keys: |
${{ runner.os }}-gatsby-build-

- name: Install dependencies
run: yarn install --immutable

- name: Build with Gatsby
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
PREFIX_PATHS: 'true'
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: yarn build

- name: Deploy to gh-pages branch
uses: peaceiris/actions-gh-pages@v4
if: ${{ github.ref == 'refs/heads/main' }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
cname: johng.io
path: ./public

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
36 changes: 0 additions & 36 deletions .github/workflows/main.yml

This file was deleted.

Empty file added .nojekyll
Empty file.
Loading