This commit is contained in:
parent
f854d60108
commit
2e4b7a93ce
2 changed files with 53 additions and 0 deletions
37
.forgejo/workflows/deploy.yml
Normal file
37
.forgejo/workflows/deploy.yml
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
name: Deploy
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- kirby
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: alpine:3.19
|
||||||
|
steps:
|
||||||
|
- name: Install packages
|
||||||
|
run: apk add --no-cache openssh
|
||||||
|
|
||||||
|
- name: Add SSH key
|
||||||
|
run: |
|
||||||
|
mkdir ~/.ssh
|
||||||
|
chmod 700 ~/.ssh
|
||||||
|
echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_ed25519
|
||||||
|
chmod 600 ~/.ssh/id_ed25519
|
||||||
|
echo "$SSH_KNOWN_HOSTS" | tr -d '\r' >> ~/.ssh/known_hosts
|
||||||
|
chmod 644 ~/.ssh/known_hosts
|
||||||
|
env:
|
||||||
|
SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}
|
||||||
|
SSH_KNOWN_HOSTS: ${{secrets.SSH_KNOWN_HOSTS}}
|
||||||
|
|
||||||
|
- name: Run deploy script on server
|
||||||
|
run: |
|
||||||
|
ssh -p "$SSH_PORT" "$SSH_USER"@"$SSH_HOST" \
|
||||||
|
"cd /var/www/marcel-kapfer.de && ./deploy.sh $BRANCH"
|
||||||
|
env:
|
||||||
|
SSH_USER: ${{secrets.SSH_USER}}
|
||||||
|
SSH_HOST: ${{secrets.SSH_HOST}}
|
||||||
|
SSH_PORT: ${{secrets.SSH_PORT}}
|
||||||
|
BRANCH: ${{vars.BRANCH}}
|
16
deploy.sh
Executable file
16
deploy.sh
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
INFO="\033[0;30m\033[47m"
|
||||||
|
NC="\033[0m"
|
||||||
|
|
||||||
|
log() {
|
||||||
|
echo -e "${INFO} INFO ${NC} $1"
|
||||||
|
}
|
||||||
|
|
||||||
|
log "Pulling latest changes from Git repository..."
|
||||||
|
git pull origin "$1"
|
||||||
|
|
||||||
|
log "Installing new composer dependencies and update autoloader..."
|
||||||
|
composer install --no-interaction --prefer-dist --optimize-autoloader
|
Loading…
Reference in a new issue