From 888e647e1f1c98fc8c61b28fc532f736249efdaf Mon Sep 17 00:00:00 2001 From: crate Date: Mon, 2 Jun 2025 13:06:23 -0500 Subject: [PATCH] add gitea deploy script --- .gitea/workflows/deploy.yaml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 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..61e2ab9 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,32 @@ +name: Garfbot CI/CD Deployment + +on: + push: + branches: [ main ] + +jobs: + Deploy: + runs-on: ubuntu-latest + container: + image: docker:latest + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - /home/crate/garfbot:/workspace + steps: + - name: Pull Garfbot and restart container + run: | + apk add --no-cache git + cd /workspace + + git pull origin main + + CHANGED=$(git diff --name-only HEAD~1 HEAD) + + if echo "$CHANGED" | grep -qE "(Dockerfile|requirements\.txt|docker-compose\.yml)"; then + docker stop garfbot + docker rm garfbot + docker build -t git.crate.zip/crate/garfbot:latest . + docker run -d --restart always -v $PWD:/usr/src/app --name garfbot git.crate.zip/crate/garfbot:latest + else + docker restart garfbot + fi