pipeline: # Build and test stage build-and-test: image: mcr.microsoft.com/dotnet/sdk:9.0 commands: # Restore dependencies - dotnet restore GermanApp/GermanApp.csproj # Build the backend - dotnet build GermanApp/GermanApp.csproj --no-restore --configuration Release # Run unit tests - dotnet test Tests/GermanApp.Tests.Unit.csproj --no-build --configuration Release --verbosity normal # Run integration tests - dotnet test Tests/GermanApp.Tests.Integration.csproj --no-build --configuration Release --verbosity normal when: # Run on all branches branch: - main - feature/* - bugfix/* - refactor/* # Docker build and push stage docker-build: image: plugins/docker settings: dockerfile: GermanApp/Dockerfile context: GermanApp registry: registry.lrhdev.dk repo: registry.lrhdev.dk/lasserh/deutschlernen tags: - latest - ${CI_COMMIT_SHA:0:8} username: from_secret: docker_username password: from_secret: docker_password when: # Only build and push on main branch branch: - main # Only run if build-and-test succeeded status: - success # Deploy stage deploy: image: alpine commands: - echo "Deploying to deutsch.lrhdev.dk..." - 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 - ssh root@deutsch.lrhdev.dk "cd /path/to/app && docker-compose pull backend && docker-compose up -d backend" secrets: - SSH_PRIVATE_KEY when: # Only deploy on main branch after successful docker-build 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. # # ============================================