50 lines
1.4 KiB
YAML
50 lines
1.4 KiB
YAML
name: hugo deploy
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
fetch-depth: 0
|
|
|
|
- name: Install Hugo
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y wget tar openssh-client git
|
|
HUGO_VERSION=0.154.1
|
|
ARCH=Linux-64bit
|
|
wget -q https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_${ARCH}.tar.gz -O /tmp/hugo.tar.gz
|
|
tar -xzf /tmp/hugo.tar.gz -C /tmp
|
|
sudo mv /tmp/hugo /usr/local/bin/hugo
|
|
hugo version
|
|
|
|
- name: Ensure submodules
|
|
run: |
|
|
git submodule sync --recursive
|
|
git submodule update --init --recursive
|
|
|
|
- name: Build site
|
|
run: |
|
|
hugo -s website -d public
|
|
|
|
- name: Configure SSH
|
|
env:
|
|
HUGO_DEPLOY_SSH_PRIVATE_KEY: ${{ secrets.HUGO_DEPLOY_SSH_PRIVATE_KEY }}
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
echo "$HUGO_DEPLOY_SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
|
chmod 600 ~/.ssh/id_rsa
|
|
|
|
- name: Deploy to server
|
|
run: |
|
|
ssh -o StrictHostKeyChecking=no hugo-deploy@10.20.20.102 "mkdir -p /opt/containers/website/content && rm -rf /opt/containers/website/content/*"
|
|
scp -r public/* hugo-deploy@10.20.20.102:/opt/containers/website/content/
|