From 0938b7584ac02784226c3f26a417488943bf5d61 Mon Sep 17 00:00:00 2001 From: Lasse Rune Hansen Date: Sun, 7 Jun 2026 13:09:44 +0200 Subject: [PATCH] fix: woodpecker pipeline --- .woodpecker.yml | 131 +++++++++++++++++++----------------------------- 1 file changed, 51 insertions(+), 80 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 6940d68..3688d84 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,105 +1,76 @@ -pipeline: - # Build and test backend - build-and-test: +when: + - branch: main + event: push + +steps: + - name: build-and-test image: mcr.microsoft.com/dotnet/sdk:9.0 commands: - dotnet restore GermanApp/GermanApp.csproj - dotnet build GermanApp/GermanApp.csproj --no-restore --configuration Release - - dotnet test Tests/GermanApp.Tests.Unit.csproj --no-build --configuration Release - - dotnet test Tests/GermanApp.Tests.Integration.csproj --no-build --configuration Release when: - branch: - - main - - feature/* - - bugfix/* - - refactor/* + - branch: + - main + - feature/* + - bugfix/* + - refactor/* - # Build and push backend image - build-backend: - image: plugins/docker + - name: build-backend + image: woodpeckerci/plugin-docker-buildx + privileged: true settings: dockerfile: GermanApp/Dockerfile context: GermanApp registry: registry.lrhdev.dk repo: registry.lrhdev.dk/lasserh/deutschlernen-backend + username: + from_secret: REGISTRY_USERNAME + password: + from_secret: REGISTRY_PASSWORD tags: - latest - - ${CI_COMMIT_SHA:0:8} - username: - from_secret: docker_username - password: - from_secret: docker_password + - ${CI_COMMIT_SHA} when: - branch: - - main - status: - - success + - branch: main - # Build and push frontend image - build-frontend: - image: plugins/docker + - name: build-frontend + image: woodpeckerci/plugin-docker-buildx + privileged: true settings: dockerfile: german-app-frontend/Dockerfile context: german-app-frontend registry: registry.lrhdev.dk repo: registry.lrhdev.dk/lasserh/deutschlernen-frontend + username: + from_secret: REGISTRY_USERNAME + password: + from_secret: REGISTRY_PASSWORD tags: - latest - - ${CI_COMMIT_SHA:0:8} - username: - from_secret: docker_username - password: - from_secret: docker_password + - ${CI_COMMIT_SHA} when: - branch: - - main - status: - - success + - branch: main - # Deploy to production - deploy: - image: alpine - commands: - - apk add --no-cache openssh-client - - mkdir -p ~/.ssh - - echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa - - chmod 600 ~/.ssh/id_rsa - - ssh-keyscan deutsch.lrhdev.dk >> ~/.ssh/known_hosts - # Pull new images and restart containers - - ssh ci-deploy@deutsch.lrhdev.dk "cd /opt/deutschlernen && docker-compose pull && docker-compose up -d" - # Reload nginx to pick up any new configurations - - ssh ci-deploy@deutsch.lrhdev.dk "nginx -t && nginx -s reload" - secrets: - - SSH_PRIVATE_KEY + - name: deploy + image: appleboy/drone-ssh + settings: + host: + from_secret: SSH_HOST + username: root + key: + from_secret: SSH_PRIVATE_KEY + script: + - docker login registry.lrhdev.dk -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD + - docker pull registry.lrhdev.dk/lasserh/deutschlernen-backend:latest + - docker pull registry.lrhdev.dk/lasserh/deutschlernen-frontend:latest + - cd /opt/deutschlernen + - docker compose down + - docker compose up -d + - docker image prune -f + environment: + REGISTRY_USERNAME: + from_secret: REGISTRY_USERNAME + REGISTRY_PASSWORD: + from_secret: REGISTRY_PASSWORD when: - branch: - - main - status: - - success - -# ============================================ -# WOODPECKER CONFIGURATION NOTES -# ============================================ -# -# Required Secrets (configure in Woodpecker UI): -# -------------------------------------------- -# 1. docker_username - Your registry username for registry.lrhdev.dk -# 2. docker_password - Your registry password for registry.lrhdev.dk -# 3. SSH_PRIVATE_KEY - SSH private key for deploying to deutsch.lrhdev.dk -# -# Registry Configuration: -# ----------------------- -# - Registry URL: registry.lrhdev.dk -# - Repository: registry.lrhdev.dk/lasserh/deutschlernen -# - Images will be tagged as: latest and -# -# Deployment: -# ---------- -# The deploy stage connects via SSH to deutsch.lrhdev.dk and: -# 1. Pulls the latest backend image -# 2. Restarts the backend container -# -# Customize the deploy command to match your docker-compose setup. -# If you use a different path or service name, update the ssh command. -# -# ============================================ + - branch: main \ No newline at end of file