feat: add auto deployment via forgejo actions
All checks were successful
/ test (push) Successful in 3m20s

This commit is contained in:
s3lph 2024-04-07 01:01:52 +02:00
parent aac9357a96
commit 433b443374
Signed by: s3lph
GPG key ID: 0AA29A52FB33CFB5
4 changed files with 46 additions and 14 deletions

View file

@ -0,0 +1,29 @@
---
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ipv6
env:
SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
RSYNC_DEST: ${{ secrets.RSYNC_DEST }}
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- name: test
run: |
apt-get update
apt-get install --yes --no-install-recommends make hugo rsync
make clean generate
- name: upload
run: |
echo "$SSH_KNOWN_HOSTS" > /ssh_known_hosts
echo "$SSH_PRIVATE_KEY" > /ssh_private_key
chmod 0600 /ssh_private_key
rsync -v --recursive --delete -e "ssh -oUserKnownHostsFile=/ssh_known_hosts -i /ssh_private_key" "public/" "$RSYNC_DEST"

View file

@ -0,0 +1,15 @@
---
on: push
jobs:
test:
runs-on: docker
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- name: test
run: |
apt-get update
apt-get install --yes --no-install-recommends make hugo rsync
make clean generate

View file

@ -8,11 +8,6 @@ OUTPUT_DIR := public
VNU_COMMAND := vnu
VNU_OPTIONS := --skip-non-html --also-check-css
# Rsync deployment configuration.
SSH_HOST := www.cosin.ch
SSH_USER := webcosin
TARGET_DIR := /srv/www/www.cosin.ch/
# Non-file goals.
.PHONY: server generate validate upload clean
@ -31,10 +26,6 @@ generate:
validate: generate
$(VNU_COMMAND) $(VNU_OPTIONS) $(OUTPUT_DIR)
# Deploy the website to the production webserver.
upload: generate
rsync --rsh=ssh -P -rvzc --cvs-exclude --delete $(OUTPUT_DIR)/ $(SSH_USER)@$(SSH_HOST):$(TARGET_DIR)
# Clean up.
clean:
rm -rf $(OUTPUT_DIR)

View file

@ -22,8 +22,5 @@ and auto-reloads on content changes.
Deployment
----------
Given the necessary _ssh_ login credentials, just run:
make upload
to upload the static website to our webserver via _rsync_ over _ssh_.
The `master` branch is deployed to https://cosin.ch automatically via
Forgejo Actions.