feat: add auto deployment via forgejo actions #1
4 changed files with 46 additions and 14 deletions
29
.forgejo/workflows/deploy.yml
Normal file
29
.forgejo/workflows/deploy.yml
Normal 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"
|
||||
|
15
.forgejo/workflows/test.yml
Normal file
15
.forgejo/workflows/test.yml
Normal 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
|
9
Makefile
9
Makefile
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue