Skip to content

Commit

Permalink
Resotred Github deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscarrollsmith committed Mar 18, 2024
1 parent 17c1764 commit d409e83
Show file tree
Hide file tree
Showing 5 changed files with 359 additions and 184 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build and deploy via gh-pages branch

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: 'lts/*'

- name: Cache node modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Check and prepare homepage URL
id: check
run: |
HOMEPAGE=$(node -p "require('./package.json').homepage")
STRIPPED_HOMEPAGE=${HOMEPAGE#http://}
STRIPPED_HOMEPAGE=${STRIPPED_HOMEPAGE#https://}
echo "::set-output name=stripped_homepage::$STRIPPED_HOMEPAGE"
if [[ ${HOMEPAGE: -10} != ".github.io" ]]; then
echo "::set-output name=run_cname::true"
else
echo "::set-output name=run_cname::false"
fi
- name: Set CNAME
if: steps.check.outputs.run_cname == 'true'
run: echo ${{ steps.check.outputs.stripped_homepage }} > ./dist/CNAME

- name: Deploy
run: npm run deploy
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ node_modules
dist
dist-ssr
*.local
.github

# Editor directories and files
.vscode/*
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ This is a super tedious process with a lot of wait time built in, but hopefully
Additionally, to use a custom domain, you will need to make a couple changes to your repo's `package.json` file:

1. Change the "homepage" attribute to your custom domain (e.g., "https://{your-domain}.com).
2. Change the "deploy" command in `package.json` from "gh-pages -d dist" to "echo {your-domain}.com > ./dist/CNAME && gh-pages -d dist". (Obviously, replace the curly braces with your custom domain name.)
2. Update the "cname" command in `package.json` with your custom domain name, and make sure to run this before deploying from a local machine.
Loading

0 comments on commit d409e83

Please sign in to comment.