Skip to content

Commit 765e81a

Browse files
committed
Status endpoint
1 parent 94c4f3e commit 765e81a

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

.github/workflows/ghpages-deploy.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@ jobs:
2828

2929
- name: Install dependencies
3030
run: |
31+
sudo apt-get install -y jq sponge
3132
npm install
3233
3334
- name: Process UCD XML to JSON
3435
run: |
3536
./bin/ucd_download.sh
3637
./bin/ucd_to_json.ts
3738
39+
- name: Set Status Info
40+
run: |
41+
./bin/set_status.sh
42+
3843
- name: Build
3944
run: |
4045
npm run build

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+
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}" | sponge "${STATUS_FILE}"
40+
41+
echo "INFO: completed at $(date -u +"%Y-%m-%dT%H:%M:%SZ")"

public/status.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"success":true,"message":"OK","tech":"(local)","lastmod":"(local)","commit":"(local)"}

0 commit comments

Comments
 (0)