From 537cc89674e9e8364d7ef5a71b8178d81ffeed11 Mon Sep 17 00:00:00 2001 From: colin Date: Sun, 2 Feb 2025 14:03:41 -0500 Subject: [PATCH] Update .woodpecker.yml --- .woodpecker.yml | 162 +++++++++++++++++++++--------------------------- 1 file changed, 72 insertions(+), 90 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index ba8bf97..1b53d12 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -1,7 +1,6 @@ -# build 0 -labels: # "master=true" - hostname: "macmini8" - # master: "true" +labels: + location: manager + clone: git: image: woodpeckerci/plugin-git @@ -9,141 +8,124 @@ clone: partial: false depth: 1 recursive: true - # use-ssh: true steps: - # Build Step for staging Branch - build-staging: - name: build-staging + # Build and Push for Staging + build-push-staging: + name: build-push-staging image: woodpeckerci/plugin-docker-buildx - secrets: [REGISTRY_USER, REGISTRY_PASSWORD] + environment: + REGISTRY_USER: + from_secret: REGISTRY_USER + REGISTRY_PASSWORD: + from_secret: REGISTRY_PASSWORD + DOCKER_REGISTRY_USER: + from_secret: DOCKER_REGISTRY_USER + DOCKER_REGISTRY_PASSWORD: + from_secret: DOCKER_REGISTRY_PASSWORD volumes: - /var/run/docker.sock:/var/run/docker.sock commands: - - echo "Building application for staging branch" + - echo "Logging into registries" + - echo "$${DOCKER_REGISTRY_PASSWORD}" | docker login -u "$${DOCKER_REGISTRY_USER}" --password-stdin - echo "$${REGISTRY_PASSWORD}" | docker login -u "$${REGISTRY_USER}" --password-stdin git.nixc.us - - echo compose build - - docker compose -f docker-compose.staging.yml build --no-cache + - echo "Building and pushing application for staging" + - docker compose -f docker-compose.staging.yml build --no-cache + - docker compose -f docker-compose.staging.yml push when: branch: main event: push - # path: - # include: [ 'stack.production.yml', 'stack.staging.yml', 'docker-compose.staging.yml', 'docker-compose.production.yml', 'Dockerfile', '*.tests.ts' ] - deploy-new: - name: deploy-new - when: - branch: main - # path: - # include: [ 'stack.production.yml', 'stack.staging.yml', 'docker-compose.staging.yml', 'docker-compose.production.yml', 'Dockerfile', '*.tests.ts' ] + # Deploy Staging + deploy-staging: + name: deploy-staging image: woodpeckerci/plugin-docker-buildx - secrets: [REGISTRY_USER, REGISTRY_PASSWORD] + environment: + REGISTRY_USER: + from_secret: REGISTRY_USER + REGISTRY_PASSWORD: + from_secret: REGISTRY_PASSWORD volumes: - /var/run/docker.sock:/var/run/docker.sock commands: + - echo "Deploying to staging environment" - echo "$${REGISTRY_PASSWORD}" | docker login -u "$${REGISTRY_USER}" --password-stdin git.nixc.us - - echo compose push - - docker compose -f docker-compose.staging.yml push - # - docker stack deploy --with-registry-auth -c ./stack.staging.yml $${CI_REPO_NAME}-staging - - # # Wait for Deploy to Complete - # wait-for-deploy-staging: - # name: wait-for-deploy-staging - # image: woodpeckerci/plugin-git - # commands: - # - echo "Waiting for staging deploy step to complete rollout." - # - sleep 60 - # when: - # - branch: main - # - event: push - - # # Run Automated Tests on staging Branch - # test-staging: - # name: run-tests-staging - # image: git.nixc.us/colin/playwright:latest - # secrets: [ base_url ] - # when: - # - branch: main - # - event: push - # - path: - # include: [ 'tests/', 'src/','docker-compose.staging.yml', 'docker-compose.production.yml', '*.tests.ts' ] # Specify paths relevant to tests - # volumes: - # - /var/run/docker.sock:/var/run/docker.sock:ro + - docker stack deploy --with-registry-auth -c ./stack.staging.yml $${CI_REPO_NAME}-staging + when: + branch: main + event: push + # Cleanup Staging cleanup-staging: name: cleanup-staging - when: - branch: main - # path: - # include: [ 'stack.production.yml', 'stack.staging.yml', 'docker-compose.staging.yml', 'docker-compose.production.yml', 'Dockerfile', '*.tests.ts' ] image: woodpeckerci/plugin-docker-buildx - secrets: [REGISTRY_USER, REGISTRY_PASSWORD] + environment: + REGISTRY_USER: + from_secret: REGISTRY_USER + REGISTRY_PASSWORD: + from_secret: REGISTRY_PASSWORD volumes: - /var/run/docker.sock:/var/run/docker.sock commands: - # - docker stack rm $${CI_REPO_NAME}-staging - ## added fault tolerance for docker stack rm + - echo "Cleaning up staging environment" - for i in {1..5}; do docker stack rm ${CI_REPO_NAME}-staging && break || sleep 10; done - docker compose -f docker-compose.staging.yml down - docker compose -f docker-compose.staging.yml rm -f + when: + branch: main + event: push - # Build Step for staging Branch + # Build and Push for Production build-push-production: name: build-push-production image: woodpeckerci/plugin-docker-buildx - secrets: [REGISTRY_USER, REGISTRY_PASSWORD] + environment: + REGISTRY_USER: + from_secret: REGISTRY_USER + REGISTRY_PASSWORD: + from_secret: REGISTRY_PASSWORD + DOCKER_REGISTRY_USER: + from_secret: DOCKER_REGISTRY_USER + DOCKER_REGISTRY_PASSWORD: + from_secret: DOCKER_REGISTRY_PASSWORD volumes: - /var/run/docker.sock:/var/run/docker.sock commands: - - echo "Building application for staging branch" + - echo "Logging into registries" + - echo "$${DOCKER_REGISTRY_PASSWORD}" | docker login -u "$${DOCKER_REGISTRY_USER}" --password-stdin - echo "$${REGISTRY_PASSWORD}" | docker login -u "$${REGISTRY_USER}" --password-stdin git.nixc.us - - echo compose build + - echo "Building and pushing application for production" - docker compose -f docker-compose.production.yml build --no-cache - docker compose -f docker-compose.production.yml push when: branch: main event: [push, cron] - # path: - # include: [ 'stack.production.yml', 'stack.staging.yml', 'docker-compose.staging.yml', 'docker-compose.production.yml', 'Dockerfile', '*.tests.ts' ] - # Deploy to Production Branch + # Deploy Production deploy-production: name: deploy-production image: woodpeckerci/plugin-docker-buildx - secrets: [REGISTRY_USER, REGISTRY_PASSWORD] + environment: + REGISTRY_USER: + from_secret: REGISTRY_USER + REGISTRY_PASSWORD: + from_secret: REGISTRY_PASSWORD volumes: - /var/run/docker.sock:/var/run/docker.sock commands: + - echo "Deploying to production environment" - echo "$${REGISTRY_PASSWORD}" | docker login -u "$${REGISTRY_USER}" --password-stdin git.nixc.us - docker stack deploy --with-registry-auth -c ./stack.production.yml $${CI_REPO_NAME} - # - docker image rm git.nixc.us/colin/$${CI_REPO_NAME}:production when: branch: main event: [push, cron] - # path: - # include: [ 'stack.production.yml', 'stack.staging.yml', 'docker-compose.staging.yml', 'docker-compose.production.yml', 'Dockerfile', '*.tests.ts' ] - - # # Wait for Deploy to Complete - # wait-for-deploy-production: - # name: wait-for-deploy-production - # image: woodpeckerci/plugin-git - # commands: - # - echo "Waiting for deploy step to complete rollout." - # - sleep 60 - # when: - # branch: main - # event: push - - # # Run Post-Deployment Smoke Tests - # post-deploy-smoke-tests-git-nixc-us: - # name: run-post-deploy-smoke-tests-git-nixc-us - # image: git.nixc.us/colin/playwright:latest - # # secrets: [TEST_USER, TEST_PASSWORD] - # environment: - # - BASE_URL=https://git.nixc.us - # when: - # branch: main - # event: push - # # path: - # # include: [ 'stack.production.yml', 'stack.staging.yml', 'docker-compose.staging.yml', 'docker-compose.production.yml', 'Dockerfile', '*.tests.ts' ] \ No newline at end of file + # Post-Deployment Smoke Tests + post-deploy-smoke-tests: + name: run-post-deploy-smoke-tests + image: git.nixc.us/colin/playwright:latest + environment: + BASE_URL: https://git.nixc.us + when: + branch: main + event: push