Skip to content

Commit

Permalink
Fix deployment action
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffreyTerry committed Sep 7, 2024
1 parent 43ee59f commit 371c386
Show file tree
Hide file tree
Showing 6 changed files with 16,283 additions and 26,617 deletions.
58 changes: 28 additions & 30 deletions .github/workflows/gatsby.yml → .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,38 +30,44 @@ defaults:
shell: bash

jobs:
# Test job
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
- name: Install dependencies
# A couple of package version are conflicting, so I have to use `--legacy-peer-deps` at the moment
run: npm install --include=dev --legacy-peer-deps
- name: Check types
id: type-check
run: npm run type-check
- name: Run Jest
id: test
run: npm test

# Build job
build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect package manager
id: detect-package-manager
run: |
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
cache: npm
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
with:
# Automatically inject pathPrefix in your Gatsby configuration file.
#
# You may remove this line if you want to manage the configuration yourself.
static_site_generator: gatsby
- name: Restore cache
Expand All @@ -74,32 +80,24 @@ jobs:
restore-keys: |
${{ runner.os }}-gatsby-build-
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
# A couple of package version are conflicting, so I have to use `--legacy-peer-deps` at the moment
run: npm install --legacy-peer-deps
- name: Build with Gatsby
env:
PREFIX_PATHS: 'true'
run: ${{ steps.detect-package-manager.outputs.manager }} run build
PREFIX_PATHS: "true"
run: npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./public

# Testing job
test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Test
id: test
run: npm test

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: test
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
Expand Down
6 changes: 0 additions & 6 deletions deploy.sh

This file was deleted.

1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
globals: {
__PATH_PREFIX__: ``,
},
testEnvironment: "jsdom",
testEnvironmentOptions: {
url: `http://localhost`,
},
Expand Down
Loading

0 comments on commit 371c386

Please sign in to comment.