whatnow.site/.gitea/workflows/build_hugo.yaml
Corbin Bartsch a6565057fb
All checks were successful
Build, test, and deploy Hugo site / build-hugo (push) Successful in 23s
Add nginx container
2025-04-02 22:10:12 -04:00

39 lines
1.6 KiB
YAML

---
name: Build, test, and deploy Hugo site
run-name: ${{ gitea.actor }} is building, testing, and deploying the static page
on:
push:
branches:
- master
jobs:
build-hugo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
github-server-url: 'https://git.cbarts.net/'
- name: Install apt packages
run: apt update && apt install -y jq rsync
- name: Get latest Hugo version
run: |
url=$(curl --silent "https://api.github.com/repos/gohugoio/hugo/releases/latest" | jq -r '.assets[] | select(.name | contains("linux-amd64.tar.gz")) | .browser_download_url' | grep -E 'hugo_[0-9]+\.[0-9]+\.[0-9]+_linux-amd64.tar.gz')
wget -P /tmp/hugo/ "$url"
version=$(echo "$url" | grep -oP 'hugo_\K[0-9]+\.[0-9]+\.[0-9]+')
echo "Downloaded Hugo version: $version"
- name: Unpack Hugo
run: tar -xf /tmp/hugo/* -C ${{ gitea.workspace }}/bin
- name: Build the static webpage
run: ${{ gitea.workspace }}/bin/hugo -s ${{ gitea.workspace }}/src -d ${{ gitea.workspace }}/public --minify
- name: Test static page
run: bash ${{ gitea.workspace}}/bin/test_static_page.sh
- name: Copy private key
run: |
echo "${{ secrets.ACT_RUNNER_KEY }}" > /tmp/act_runner_key
chmod 600 /tmp/act_runner_key
- name: rsync public directory
run: |
rsync -avz --delete -e "ssh -i /tmp/act_runner_key -o StrictHostKeyChecking=no" ${{ gitea.workspace }}/public/* act_runner@whatnow.site:/var/media/nginx/html/