From 3250700c4f9274ce98c11b6e822a772e12b6cc83 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Wed, 14 May 2025 19:35:23 -0300 Subject: [PATCH] Add Gitea Actions deployment workflow - Adds a workflow to deploy to the server on master pushes. - Uses secrets for SSH key, host, user, and port. - Installs necessary dependencies within the workflow. - Stashes local changes and pulls the latest changes via SSH. - Executes the build script after pulling the latest changes. --- .gitea/workflows/deploy.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..5952936 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,36 @@ +name: Deploy to Server + +on: + push: + branches: + - master + +jobs: + deploy: + runs-on: docker + container: + image: alpine:latest + + steps: + - name: Install dependencies + run: | + apk add --no-cache openssh git bash + + - name: Setup SSH + run: | + mkdir -p ~/.ssh + echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + chmod 700 ~/.ssh + ssh-keyscan "$SSH_HOST" >> ~/.ssh/known_hosts + chmod 644 ~/.ssh/known_hosts + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + SSH_HOST: ${{ secrets.SSH_HOST }} + + - name: Deploy via SSH + run: | + ssh -p "$SSH_PORT" "$SSH_USER@$SSH_HOST" 'cd /home/rogsme/repo && git stash && git pull --force origin master && ./build.sh' + env: + SSH_USER: ${{ secrets.SSH_USER }} + SSH_HOST: ${{ secrets.SSH_HOST }} + SSH_PORT: ${{ secrets.SSH_PORT }}