From 3be5a14a08898a18756c84e991e3b1099848aa8f Mon Sep 17 00:00:00 2001 From: John Goodliff Date: Mon, 17 Jun 2024 15:02:59 -0600 Subject: [PATCH 1/3] Add .nojekyll file to prevent building with Jekyll --- .nojekyll | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .nojekyll diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 00000000..e69de29b From 0a915d88b7595acece98c862e9c26b25692d03af Mon Sep 17 00:00:00 2001 From: John Goodliff Date: Mon, 17 Jun 2024 16:26:06 -0600 Subject: [PATCH 2/3] Remove old Gatsby deploy workflow --- .github/workflows/main.yml | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 2a58558f..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,36 +0,0 @@ -# name: Gatsby Build & Deploy -# on: -# push: -# branches: -# - v3 -# pull_request: -# workflow_dispatch: - -# jobs: -# deploy: -# runs-on: ubuntu-latest -# concurrency: -# group: ${{ github.workflow }}-${{ github.ref }} -# steps: -# - name: Checkout repository -# uses: actions/checkout@v3 - -# - name: Setup Node.js -# uses: actions/setup-node@v3 -# with: -# node-version: '16' -# cache: 'yarn' - -# - name: Install dependencies -# run: yarn install --immutable - -# - name: Build with Gatsby -# run: DOTENV_CONFIG_GH_TOKEN=${{ secrets.JOHNGIO_DEPLOY_PAT }} yarn build - -# - name: Deploy to gh-pages branch -# uses: peaceiris/actions-gh-pages@v3 -# if: ${{ github.ref == 'refs/heads/main' }} -# with: -# personal_token: ${{ secrets.JOHNGIO_DEPLOY_PAT }} -# publish_dir: ./public -# cname: johng.io From dcbf9a05ba857ffb3c171b36cba50f2c36224bcf Mon Sep 17 00:00:00 2001 From: John Goodliff Date: Mon, 17 Jun 2024 16:28:25 -0600 Subject: [PATCH 3/3] Add cache support to deploy workflow --- .github/workflows/deploy.yml | 70 ++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 15 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e70b95d7..b70de420 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 @@ -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