64 lines
1.6 KiB
YAML
64 lines
1.6 KiB
YAML
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
# Allows external webhook trigger
|
|
repository_dispatch:
|
|
types:
|
|
- webhook
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
|
|
RUNNER_TOOL_CACHE: /toolcache
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
submodules: true # Fetch Hugo themes (true OR recursive)
|
|
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
|
|
|
|
- name: Setup Hugo
|
|
uses: https://github.com/peaceiris/actions-hugo@v2
|
|
with:
|
|
hugo-version: '0.124.0'
|
|
# extended: true
|
|
|
|
- name: Build site
|
|
run: hugo --minify
|
|
|
|
# -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
|
|
uses: https://github.com/appleboy/scp-action@master
|
|
with:
|
|
host: ${{ secrets.SSH_HOST }}
|
|
username: ${{ secrets.SSH_USER }}
|
|
key: ${{ secrets.SSH_KEY }}
|
|
source: ./website.tar
|
|
target: /tmp/
|
|
overwrite: true
|
|
|
|
- name: Extract archive
|
|
uses: https://github.com/appleboy/ssh-action@master
|
|
with:
|
|
host: ${{ secrets.SSH_HOST }}
|
|
username: ${{ secrets.SSH_USER }}
|
|
key: ${{ secrets.SSH_KEY }}
|
|
script: |
|
|
rm -r ${{ secrets.WEB_DIR }}/*
|
|
tar -xvf /tmp/website.tar --directory ${{ secrets.WEB_DIR }}/
|
|
rm /tmp/website.tar
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
path: website.tar
|
|
|