From e14799cc51bc3d31f3e18fc1f03b00234e4e5916 Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 18 Jun 2026 23:42:32 -0700 Subject: [PATCH] Add Woodpecker CI/CD pipeline configuration --- .woodpecker.yml | 98 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 .woodpecker.yml diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..a6e75fd --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,98 @@ +steps: + # Validate all compose files have valid syntax + validate: + image: docker:latest + commands: + - docker-compose config -f git.yaml > /dev/null + - echo "✓ git.yaml syntax valid" + volumes: + - /var/run/docker.sock:/var/run/docker.sock + when: + branch: main + + # Deploy to Docker Swarm + deploy: + image: alpine:latest + commands: + - apk add --no-cache openssh-client + - mkdir -p ~/.ssh + - echo "$SSH_KEY" | base64 -d > ~/.ssh/id_rsa + - chmod 600 ~/.ssh/id_rsa + - ssh-keyscan -H docker-2.local >> ~/.ssh/known_hosts 2>/dev/null || true + + # Copy compose files to swarm manager + - scp -o StrictHostKeyChecking=no -r *.yaml root@docker-2.local:/tmp/compose/ + - scp -o StrictHostKeyChecking=no *.env root@docker-2.local:/tmp/compose/ || true + + # Deploy stacks via SSH + - | + ssh -o StrictHostKeyChecking=no root@docker-2.local << 'DEPLOY' + cd /tmp/compose + docker stack deploy -c git.yaml git + echo "✓ Git stack deployed" + DEPLOY + secrets: + - ssh_key + when: + branch: main + event: push + + # Verify deployment success + verify: + image: alpine:latest + commands: + - apk add --no-cache openssh-client + - mkdir -p ~/.ssh + - echo "$SSH_KEY" | base64 -d > ~/.ssh/id_rsa + - chmod 600 ~/.ssh/id_rsa + - ssh-keyscan -H docker-2.local >> ~/.ssh/known_hosts 2>/dev/null || true + + # Check stack status + - | + ssh -o StrictHostKeyChecking=no root@docker-2.local << 'VERIFY' + echo "Git Stack Status:" + docker stack ps git + VERIFY + secrets: + - ssh_key + when: + branch: main + status: success + + # Notify Teams on success + notify-success: + image: alpine:latest + commands: + - apk add --no-cache curl + - | + curl -X POST -H 'Content-Type: application/json' \ + -d '{ + "title": "✅ Compose Deploy Success", + "text": "homelab/compose-files deployed to Docker Swarm", + "themeColor": "00aa00" + }' \ + "$TEAMS_WEBHOOK" + secrets: + - teams_webhook + when: + branch: main + status: success + + # Notify Teams on failure + notify-failure: + image: alpine:latest + commands: + - apk add --no-cache curl + - | + curl -X POST -H 'Content-Type: application/json' \ + -d '{ + "title": "❌ Compose Deploy Failed", + "text": "homelab/compose-files deployment failed", + "themeColor": "ff0000" + }' \ + "$TEAMS_WEBHOOK" + secrets: + - teams_webhook + when: + branch: main + status: failure