www.trr379.de/.forgejo/workflows/deploy.yml
Michael Hanke edfcce402b
Add workflow to auto-build and deploy
Supports both the main and the draft site. Deployment target is
determined by branch name:

- main -> draft
- published -> official
2025-03-18 09:13:38 +01:00

38 lines
1.1 KiB
YAML

name: Deploy on webserver
defaults:
run:
# hugo container only has `sh`
shell: sh
on:
push:
branches:
- main
- published
jobs:
deploy:
name: Build site with hugo and deploy on success
runs-on: trr379-hugo-site-build
container:
volumes:
# for depositing the built site directly
- /home/www/srv:/www:rw
steps:
- name: Checkout
uses: https://hub.datalad.org/forgejo/datalad-clone-action@v1
with:
recursive: true
get_content: .
- name: Generate site
run: hugo
- name: Deploy official site
if: ${{ github.ref_name == 'published' }}
run: cp -r public /www/new_www.trr379.de && mv /www/www.trr379.de /www/old_www.trr379.de; mv /www/new_www.trr379.de /www/www.trr379.de; rm -rf /www/old_www.trr379.de/
- name: Deploy draft site
if: ${{ github.ref_name == 'main' }}
run: cp -r public /www/new_www-draft.trr379.de && mv /www/www-draft.trr379.de /www/old_www-draft.trr379.de; mv /www/new_www-draft.trr379.de /www/www-draft.trr379.de; rm -rf /www/old_www-draft.trr379.de/