diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml new file mode 100644 index 0000000..526a8a6 --- /dev/null +++ b/.forgejo/workflows/build.yml @@ -0,0 +1,24 @@ +name: Build Website +on: [push] +jobs: + build: + runs-on: docker + steps: + - name: Checkout + run: | + git clone --branch ${{ github.ref_name }} ${{ github.server_url }}/${{ github.repository }}.git . + + - name: Build + run: | + docker run --rm \ + -v "$PWD/site:/src" \ + -w /src \ + ghcr.io/gohugoio/hugo:latest \ + --minify --destination "public" --baseURL "/" + + - name: Deploy + run: | + echo "${{ secrets.FORGEJO_SSH }}" > /tmp/deploy_key + chmod 600 /tmp/deploy_key + scp -i /tmp/deploy_key -o StrictHostKeyChecking=no -r site/public/. ${{ vars.JMOPINES_USER }}@${{ vars.JMOPINES_IP }}:/var/www/jmopines/ + rm /tmp/deploy_key \ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh index 1c9e668..3a3309c 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,11 +1,10 @@ #!/usr/bin/env bash set -euo pipefail -# Build and serve the Hugo site locally using Docker. +# Build the Hugo site into the `public/` directory for deployment (e.g. nginx). # Usage: ./scripts/build.sh source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../.env" -PORT="${1:-$PORT}" if [[ ! -d "${SITE_DIR}" ]]; then echo "[build] Site directory not found: ${SITE_DIR}" @@ -13,14 +12,13 @@ if [[ ! -d "${SITE_DIR}" ]]; then exit 1 fi -echo "[build] Serving site at http://localhost:${PORT}/" -echo "[build] Press Ctrl+C to stop." +echo "[build] Building site into ${SITE_DIR}/public ..." +# Run Hugo in Docker to produce static files. This does not start the dev server. docker run --rm \ -v "${SITE_DIR}:/src" \ -w /src \ - -p "${PORT}:1313" \ - "${HUGO_IMAGE}" server \ - --bind 0.0.0.0 \ - --baseURL "http://localhost:${PORT}/" \ - --appendPort=false + "${HUGO_IMAGE}" \ + --minify --destination "public" --baseURL "/" + +echo "[build] Build complete: ${SITE_DIR}/public"