jmopines/.forgejo/workflows/build.yml

66 lines
2.2 KiB
YAML
Raw Normal View History

2026-04-20 13:23:14 +00:00
name: Build Website
on: [push]
jobs:
build:
2026-04-23 21:08:28 +00:00
runs-on: shell
2026-04-20 13:23:14 +00:00
steps:
- name: Checkout
run: |
git clone --branch ${{ github.ref_name }} ${{ github.server_url }}/${{ github.repository }}.git .
2026-04-20 13:25:21 +00:00
- name: Prepare output directory
run: |
mkdir -p site/public
2026-04-20 13:26:08 +00:00
chmod 777 site
2026-04-23 21:11:39 +00:00
# - 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
2026-04-20 13:23:14 +00:00
- name: Build
run: |
2026-04-23 23:33:34 +00:00
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" \
2026-04-23 23:29:28 +00:00
-e GOPATH=/cache \
2026-04-23 23:33:34 +00:00
-w /src \
forgejo.jmopines.com/jm/hugo-git:latest \
2026-04-23 23:33:34 +00:00
--minify --destination "public" --baseURL "/"
2026-04-20 13:23:14 +00:00
- name: Deploy
run: |
2026-04-23 21:11:39 +00:00
set -ex
# Verify files exist
ls -la site/public/
# Setup SSH
2026-04-20 13:23:14 +00:00
echo "${{ secrets.FORGEJO_SSH }}" > /tmp/deploy_key
chmod 600 /tmp/deploy_key
2026-04-23 21:11:39 +00:00
# Sync with verbose output so we see what is happening
rsync -avz --delete \
2026-04-20 13:47:50 +00:00
--exclude 'resume/' \
-e "ssh -i /tmp/deploy_key -o StrictHostKeyChecking=no" \
2026-04-23 21:11:39 +00:00
site/public/ \
2026-04-20 13:47:50 +00:00
${{ vars.JMOPINES_USER }}@${{ vars.JMOPINES_IP }}:/var/www/jmopines/
2026-04-23 21:11:39 +00:00
2026-04-20 13:23:14 +00:00
rm /tmp/deploy_key