personal-website/.woodpecker/deploy-rsync.yaml

55 lines
1.8 KiB
YAML
Raw Normal View History

2024-07-15 10:51:05 +02:00
when:
- event: push
branch: [main, staging]
2024-07-15 10:57:49 +02:00
variables:
2024-07-15 10:59:54 +02:00
- &SSH_PORT '2003'
2024-07-15 10:57:49 +02:00
2024-02-29 11:23:07 +01:00
steps:
build:
2024-10-10 14:40:26 +02:00
image: golang:1.23-bookworm
2024-02-29 11:23:07 +01:00
environment:
2024-10-10 14:40:26 +02:00
HUGO_VERSION: 0.135.2
TZ: Europe/Berlin
2024-02-29 11:23:07 +01:00
commands:
- wget https://github.com/gohugoio/hugo/releases/download/v$${HUGO_VERSION}/hugo_extended_$${HUGO_VERSION}_linux-amd64.deb && apt install ./hugo_extended_$${HUGO_VERSION}_linux-amd64.deb && rm -f hugo_extended_$${HUGO_VERSION}_linux-amd64.deb
- hugo --minify --destination ./public
2024-07-15 10:49:51 +02:00
upload-prod:
2024-02-29 11:23:07 +01:00
image: alpine:latest
2024-07-15 10:49:51 +02:00
when:
- branch: main
2024-02-29 11:23:07 +01:00
secrets:
- RSYNC_SSHKEY
- RSYNC_TARGET_SERVER
- RSYNC_TARGET_USER
environment:
2024-07-15 10:59:54 +02:00
TARGET_PATH: /webroot/adora.codes
RSYNC_TARGET_PORT: *SSH_PORT
2024-02-29 11:23:07 +01:00
commands:
- apk add --update --no-cache openssh rsync git
- mkdir -p $HOME/.ssh
- echo "$RSYNC_SSHKEY" > $HOME/.ssh/id_ed25519
- chmod 0600 $HOME/.ssh/id_ed25519
2024-07-15 10:49:51 +02:00
- ssh-keyscan -t ed25519 -p $RSYNC_TARGET_PORT $RSYNC_TARGET_SERVER >> $HOME/.ssh/known_hosts
- rsync -avh -e "ssh -p $RSYNC_TARGET_PORT" --delete ./public/ $RSYNC_TARGET_USER@$RSYNC_TARGET_SERVER:$TARGET_PATH
2024-02-29 11:23:07 +01:00
2024-07-15 10:49:51 +02:00
upload-staging:
image: alpine:latest
when:
- branch: staging
secrets:
- RSYNC_SSHKEY
- RSYNC_TARGET_SERVER
- RSYNC_TARGET_USER
environment:
2024-07-15 11:05:19 +02:00
TARGET_PATH: /webroot/www-staging.adora.codes
2024-07-15 10:59:54 +02:00
RSYNC_TARGET_PORT: *SSH_PORT
2024-07-15 10:49:51 +02:00
commands:
- apk add --update --no-cache openssh rsync git
- mkdir -p $HOME/.ssh
- echo "$RSYNC_SSHKEY" > $HOME/.ssh/id_ed25519
- chmod 0600 $HOME/.ssh/id_ed25519
- ssh-keyscan -t ed25519 -p $RSYNC_TARGET_PORT $RSYNC_TARGET_SERVER >> $HOME/.ssh/known_hosts
- rsync -avh -e "ssh -p $RSYNC_TARGET_PORT" --delete ./public/ $RSYNC_TARGET_USER@$RSYNC_TARGET_SERVER:$TARGET_PATH