This commit is contained in:
parent
cf0f67d91d
commit
9a00c0d480
2 changed files with 31 additions and 9 deletions
24
.forgejo/workflows/build.yml
Normal file
24
.forgejo/workflows/build.yml
Normal file
|
|
@ -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
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
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
|
# Usage: ./scripts/build.sh
|
||||||
|
|
||||||
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../.env"
|
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../.env"
|
||||||
PORT="${1:-$PORT}"
|
|
||||||
|
|
||||||
if [[ ! -d "${SITE_DIR}" ]]; then
|
if [[ ! -d "${SITE_DIR}" ]]; then
|
||||||
echo "[build] Site directory not found: ${SITE_DIR}"
|
echo "[build] Site directory not found: ${SITE_DIR}"
|
||||||
|
|
@ -13,14 +12,13 @@ if [[ ! -d "${SITE_DIR}" ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[build] Serving site at http://localhost:${PORT}/"
|
echo "[build] Building site into ${SITE_DIR}/public ..."
|
||||||
echo "[build] Press Ctrl+C to stop."
|
|
||||||
|
|
||||||
|
# Run Hugo in Docker to produce static files. This does not start the dev server.
|
||||||
docker run --rm \
|
docker run --rm \
|
||||||
-v "${SITE_DIR}:/src" \
|
-v "${SITE_DIR}:/src" \
|
||||||
-w /src \
|
-w /src \
|
||||||
-p "${PORT}:1313" \
|
"${HUGO_IMAGE}" \
|
||||||
"${HUGO_IMAGE}" server \
|
--minify --destination "public" --baseURL "/"
|
||||||
--bind 0.0.0.0 \
|
|
||||||
--baseURL "http://localhost:${PORT}/" \
|
echo "[build] Build complete: ${SITE_DIR}/public"
|
||||||
--appendPort=false
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue