Skip to content

Commit cb0b78c

Browse files
author
Andrew Marcuse
committed
Deploy to Github Pages
1 parent c3556be commit cb0b78c

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
jobs:
14+
deploy:
15+
environment:
16+
name: github-pages
17+
url: ${{steps.deployment.outputs.page_url}}
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Node
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 24
27+
cache: 'npm'
28+
29+
- name: Install dependencies
30+
run: |
31+
sudo apt-get install -y jq moreutils
32+
npm install
33+
34+
- name: Set Status Info
35+
run: |
36+
./bin/set_status.sh
37+
38+
- name: Build
39+
run: |
40+
npm run build
41+
42+
- name: Upload Artifact
43+
uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: ./dist
46+
47+
- name: Deploy GitHub Pages
48+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ dist-ssr
2222
*.njsproj
2323
*.sln
2424
*.sw?
25+
26+
public/status.json
27+
tmp
28+
*tmp

bin/set_status.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Update status.json with the current build values
4+
#
5+
6+
set -o nounset
7+
set -o errexit
8+
set -o pipefail
9+
10+
SCRIPT_HOME="$( cd "$( dirname "$0" )" && pwd )"
11+
BASE_DIR=$(realpath "${SCRIPT_HOME}/..")
12+
13+
# check that jq is installed
14+
if ! command -v jq &> /dev/null; then
15+
echo "ERROR: jq is not installed. Please install jq to continue."
16+
exit 1
17+
fi
18+
19+
# check that sponge is installed
20+
if ! command -v sponge &> /dev/null; then
21+
echo "ERROR: sponge is not installed. Please install sponge (from moreutils) to continue."
22+
exit 1
23+
fi
24+
25+
STATUS_FILE="${BASE_DIR}/public/status.json"
26+
27+
LASTMOD=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
28+
TECH="NodeJS $(node --version)"
29+
COMMIT=$(git -C "${BASE_DIR}" rev-parse --short HEAD)
30+
31+
echo "INFO: updating status file ${STATUS_FILE}"
32+
33+
echo "{}" | jq \
34+
--arg lastmod "${LASTMOD}" \
35+
--arg tech "${TECH}" \
36+
--arg commit "${COMMIT}" \
37+
--compact-output \
38+
'.lastmod = $lastmod | .tech = $tech | .commit = $commit' \
39+
>"${STATUS_FILE}"
40+
41+
echo "INFO: completed at $(date -u +"%Y-%m-%dT%H:%M:%SZ")"

0 commit comments

Comments
 (0)