Skip to content

Semi-atomic deployment #18

Semi-atomic deployment

Semi-atomic deployment #18

Workflow file for this run

on:
push:
branches:
- master
- deploy-strato
jobs:
build:
name: Build website .tar.gz
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build .tar.gz file
run: |
docker build --tag local-img/zipper --target zipper .
docker create --name zipper local-img/zipper
docker cp zipper:/build.tar.gz ./build.tar.gz
docker rm -f zipper
shell: bash
- uses: actions/upload-artifact@v4
with:
name: build-tar-gz
path: ./build.tar.gz
deploy:
name: Deploy website to Strato
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
name: build-tar-gz
- name: Apt install sshpass
run: |
sudo apt-get update
sudo apt-get -y install sshpass
- name: Upload to Strato
env:
SSHPASS: ${{ secrets.STRATO_SSH_PASSWORD }}
run: |
sshpass -e scp -oStrictHostKeyChecking=no ./build.tar.gz ${{ secrets.STRATO_SSH_USERNAME }}@ssh.strato.com/build.tar.gz
sshpass -e ssh -oStrictHostKeyChecking=no ${{ secrets.STRATO_SSH_USERNAME }}@ssh.strato.com << EOF
rm -rf ./new-release
mkdir new-release
cd new-release
tar -xzvf ./build.tar.gz
cd ..
rm -rf ./prev-release
mv ./public ./prev-release
mv ./new-release/html ./public
rm -rf ./new-release
EOF