jmopines/.forgejo/workflows/build.yml
Jean-Michel Tremblay 7accb7b1fc
Some checks failed
Build Website / build (push) Failing after 1s
test
2026-04-23 17:13:43 -04:00

73 lines
No EOL
2.4 KiB
YAML

name: Build Website
on: [push]
jobs:
build:
runs-on: shell
steps:
- name: Checkout
run: |
git clone --branch ${{ github.ref_name }} ${{ github.server_url }}/${{ github.repository }}.git .
- name: Prepare output directory
run: |
mkdir -p site/public
chmod 777 site
# - name: Build
# run: |
# mkdir -p "$PWD/.hugo-cache"
# docker run --rm \
# -u "$(id -u):$(id -g)" \
# -v "$PWD/site:/src" \
# -v "$PWD/.git:/src/.git:ro" \
# -v "$PWD/.hugo-cache:/cache" \
# -e GOPATH=/cache \
# -w /src \
# forgejo.jmopines.com/jm/hugo-git:latest \
# --minify --destination "public" --baseURL "/"
# - name: Deploy
# run: |
# echo "${{ secrets.FORGEJO_SSH }}" > /tmp/deploy_key
# chmod 600 /tmp/deploy_key
# rsync -az --delete \
# --exclude 'resume/' \
# -e "ssh -i /tmp/deploy_key -o StrictHostKeyChecking=no" \
# site/public/. \
# ${{ vars.JMOPINES_USER }}@${{ vars.JMOPINES_IP }}:/var/www/jmopines/
# rm /tmp/deploy_key
- name: Build
run: |
set -ex
# 1. Create the cache and force it to be writable by the Docker container
mkdir -p "$PWD/.hugo-cache"
chmod -R 777 "$PWD/.hugo-cache"
# 2. Run Hugo
docker run --rm \
-v "$PWD:/src" \
-v "$PWD/.hugo-cache:/cache" \
-e GOPATH=/cache \
-e HUGO_CACHEDIR=/cache \
-w /src/site \
forgejo.jmopines.com/jm/hugo-git:latest \
--minify --enableGitInfo --destination "public" --baseURL "/"
# 3. Fix permissions back so the forgejo user can read the output
sudo chmod -R 755 site/public
- name: Deploy
run: |
set -ex
# Verify files exist
ls -la site/public/
# Setup SSH
echo "${{ secrets.FORGEJO_SSH }}" > /tmp/deploy_key
chmod 600 /tmp/deploy_key
# Sync with verbose output so we see what is happening
rsync -avz --delete \
--exclude 'resume/' \
-e "ssh -i /tmp/deploy_key -o StrictHostKeyChecking=no" \
site/public/ \
${{ vars.JMOPINES_USER }}@${{ vars.JMOPINES_IP }}:/var/www/jmopines/
rm /tmp/deploy_key