website/.gitea/workflows/build_and_deploy.yaml
Filip Rojek 5623e8ab00
All checks were successful
Build and Deploy Zola Website / build_and_deploy (push) Successful in 16s
Zola workflow updated
2024-10-14 17:03:56 +02:00

49 lines
1.3 KiB
YAML

name: Build and Deploy Zola Website
on:
push:
branches:
- master
- dev
env:
ZOLA_VERSION: "0.19.2"
HOST: ${{ secrets.SERVER_IP }}
SSH_USERNAME: ${{ secrets.USERNAME }}
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_KEY }}
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up Zola
run: |
wget https://github.com/getzola/zola/releases/download/v${ZOLA_VERSION}/zola-v${ZOLA_VERSION}-x86_64-unknown-linux-gnu.tar.gz
tar -xvzf *.tar.gz
- name: Build Zola Website
run: |
./zola build
- name: Set Destination Folder if MASTER
if: ${{ github.ref == 'refs/heads/master' }}
run: echo "DEST_FOLDER=/srv/www/cz/filiprojek/www" >> $GITHUB_ENV
- name: Set Destination Folder if DEV
if: ${{ github.ref == 'refs/heads/dev' }}
run: echo "DEST_FOLDER=/srv/www/cz/filiprojek/dev" >> $GITHUB_ENV
- name: Deploy
run: |
apt update -y && apt-get install -y --no-install-recommends rsync
eval "$(ssh-agent -s)"
ssh-add - <<< "${SSH_PRIVATE_KEY}"
mkdir -p ~/.ssh/
ssh-keyscan -H ${HOST} >> ~/.ssh/known_hosts
rsync -r --delete-after public/* "${SSH_USERNAME}@${HOST}:${{ env.DEST_FOLDER }}"