personal-site/cicd/scripts/build.sh
badbl0cks 1fbcbf772a
All checks were successful
Build And Deploy / build-and-deploy (push) Successful in 1m22s
Enable WireGuard service, change HTTPFetchClient to use wireguard proxy, and add required env vars
Add WireGuard-related env variables to .env.example (addresses,
keys, endpoint, DNS)
Resolve WIREGUARD_ENDPOINT_HOST to WIREGUARD_ENDPOINT_IP in
cicd/scripts/deploy.sh and write it to .env, failing if unresolved
Un-comment and enable the wireguard service in docker-compose.yml
Remove an obsolete commented workflow snippet
2026-02-07 17:44:58 -08:00

30 lines
894 B
Bash
Executable file

#!/bin/bash
set -eu
#######################
# VARIABLES #
#######################
ROOT_DIR=$(dirname $(dirname $(dirname $(realpath $0))))
GIT_REF=${GIT_REF:-main}
### NO EDITS BELOW THIS LINE ###
cd ${ROOT_DIR}
source .env
git checkout ${GIT_REF}
GIT_SHA=$(git rev-parse --short HEAD)
if [[ "${GIT_REF}" =~ ^refs/tags/v([0-9]+\.[0-9]+\.[0-9]+)(-.*)?$ ]]; then
VERSION="${BASH_REMATCH[1]}"
if [[ -n "${BASH_REMATCH[2]}" ]]; then
VERSION="${VERSION}${BASH_REMATCH[2]}"
fi
echo "Using git tag version: ${VERSION}"
else
VERSION=$(node -p "require('./package.json').version || '0.0.0'")
GIT_SHA_SHORT="${GIT_SHA:0:7}"
VERSION="${VERSION}-${GIT_SHA_SHORT}"
echo "Using package.json + SHA version: ${VERSION}"
fi
docker build -t ${IMAGE_NAME}:latest -t ${IMAGE_NAME}:v${VERSION} --build-arg VERSION=${VERSION} .
docker save -o ${IMAGE_FILENAME} ${IMAGE_NAME}:latest