mziesel.com/.gitea/workflows/hugo.yaml

64 lines
1.6 KiB
YAML
Raw Permalink Normal View History

2023-06-12 18:29:31 +00:00
on:
push:
2023-06-13 17:16:53 +00:00
branches:
2023-06-13 17:22:12 +00:00
- main
2023-06-13 17:16:53 +00:00
pull_request:
2023-10-01 21:48:20 +00:00
workflow_dispatch:
# Allows external webhook trigger
repository_dispatch:
types:
- webhook
2023-06-12 18:29:31 +00:00
jobs:
2023-06-13 17:16:53 +00:00
deploy:
2023-06-12 18:29:31 +00:00
runs-on: ubuntu-latest
2024-04-27 17:43:44 +00:00
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
RUNNER_TOOL_CACHE: /toolcache
2023-06-12 18:29:31 +00:00
steps:
2023-06-13 17:16:53 +00:00
- uses: actions/checkout@v3
2023-06-12 18:29:31 +00:00
with:
2023-06-13 17:16:53 +00:00
submodules: true # Fetch Hugo themes (true OR recursive)
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
2023-06-12 20:15:41 +00:00
2023-06-13 17:16:53 +00:00
- name: Setup Hugo
uses: https://github.com/peaceiris/actions-hugo@v2
2023-06-12 18:29:31 +00:00
with:
2024-04-27 17:28:07 +00:00
hugo-version: '0.124.0'
2023-06-13 17:16:53 +00:00
# extended: true
2023-06-12 18:29:31 +00:00
2023-06-13 17:22:12 +00:00
- name: Build site
2023-06-13 17:16:53 +00:00
run: hugo --minify
2023-09-30 18:02:41 +00:00
2024-04-27 17:28:07 +00:00
# -C switch means cd to public and then tar all contents
- name: Create tarfile
run: tar -cf website.tar -C public .
- name: Deploy to server
2024-04-27 17:51:25 +00:00
uses: https://github.com/appleboy/scp-action@master
2024-04-27 17:55:44 +00:00
with:
2024-04-27 17:51:25 +00:00
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
source: ./website.tar
2024-04-27 17:59:19 +00:00
target: /tmp/
2024-04-27 17:51:25 +00:00
overwrite: true
2024-04-27 18:29:59 +00:00
- name: Extract archive
2024-04-27 18:09:03 +00:00
uses: https://github.com/appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
2024-04-27 18:26:02 +00:00
script: |
rm -r ${{ secrets.WEB_DIR }}/*
tar -xvf /tmp/website.tar --directory ${{ secrets.WEB_DIR }}/
rm /tmp/website.tar
2023-09-30 18:13:49 +00:00
2024-04-27 17:28:07 +00:00
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: website.tar
2023-07-08 18:18:37 +00:00