From 30e512c24285f2ced346e5acad0a144bada70adc Mon Sep 17 00:00:00 2001 From: informaticker Date: Sun, 3 Nov 2024 23:17:24 +0100 Subject: [PATCH] Initial commit --- .gitea/workflows/deploy.yaml | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .gitea/workflows/deploy.yaml diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..e85377f --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,37 @@ +name: Deploy +run-name: Deploying to production +on: [push] +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup SSH + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + HOST1: ${{ secrets.HOST1 }} + USER: ${{ secrets.USER }} + run: | + mkdir -p ~/.ssh + echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + ssh-keyscan -H $HOST1 >> ~/.ssh/known_hosts + + - name: Deploy to first host + env: + HOST1: ${{ secrets.HOST1 }} + USER: ${{ secrets.USER }} + run: | + ssh $USER@$HOST1 'rm -rf /var/www/elia.network/html/*' + rsync -avz --delete \ + --exclude '.git*' \ + ./ $USER@$HOST1:/var/www/elia.network/html/ + + - name: Reload Nginx + env: + HOST1: ${{ secrets.HOST1 }} + USER: ${{ secrets.USER }} + run: | + ssh $USER@$HOST1 'sudo systemctl reload nginx'