From 77a47c42d9756043c05101e4b3bfd5cd8e242f3b Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sun, 11 Jan 2026 15:35:30 -0600 Subject: [PATCH] Let's test deploying automatically from dev to prod --- bitbucket-pipelines.yml | 54 +++++++++++++++++++++++------------- scripts/verify-deployment.sh | 7 ++++- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index 2bfd93c..84cd034 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -1,4 +1,4 @@ ---- +--- image: atlassian/default-image:2 definitions: @@ -74,25 +74,32 @@ pipelines: services: - docker - step: - name: Deploy coturn/coturn-dns to production + name: Deploy, Verify and Test Production deployment: production + image: node:22 script: - - pipe: atlassian/kubectl-run:1.1.2 - variables: - KUBE_CONFIG: $KUBE_CONFIG_PRD - KUBECTL_COMMAND: '-n coturn rollout restart deployment/coturn' - - pipe: atlassian/kubectl-run:1.1.2 - variables: - KUBE_CONFIG: $KUBE_CONFIG_PRD - KUBECTL_COMMAND: '-n coturn rollout status -w deployment/coturn' - - pipe: atlassian/kubectl-run:1.1.2 - variables: - KUBE_CONFIG: $KUBE_CONFIG_PRD - KUBECTL_COMMAND: '-n coturn-dns rollout restart deployment/coturn-dns' - - pipe: atlassian/kubectl-run:1.1.2 - variables: - KUBE_CONFIG: $KUBE_CONFIG_PRD - KUBECTL_COMMAND: '-n coturn-dns rollout status -w deployment/coturn-dns' + - apt-get update && apt-get install -y curl jq git + - curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + - install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl + - echo $KUBE_CONFIG_PRD | base64 -d > kubeconfig + - export KUBECONFIG=$(pwd)/kubeconfig + - kubectl -n coturn rollout restart deployment/coturn + - kubectl -n coturn rollout status -w deployment/coturn + - kubectl -n coturn-dns rollout restart deployment/coturn-dns + - kubectl -n coturn-dns rollout status -w deployment/coturn-dns + - chmod +x scripts/verify-deployment.sh + - ./scripts/verify-deployment.sh $BITBUCKET_COMMIT production + - npx playwright install-deps + - git clone --depth 1 git@bitbucket.org:jamkazam/video-e2e.git + - cd video-e2e + - npm install + - npx playwright install chromium + - ./bin/production-test + after-script: + - | + if [ $BITBUCKET_EXIT_CODE -ne 0 ]; then + curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"🚨 Pipeline Failed: Production verification/tests failed for commit $BITBUCKET_COMMIT. \"}" https://hooks.slack.com/services/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 + fi develop: - parallel: - step: @@ -177,6 +184,15 @@ pipelines: if [ $BITBUCKET_EXIT_CODE -ne 0 ]; then curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"🚨 Pipeline Failed: Staging verification/tests failed for commit $BITBUCKET_COMMIT. \"}" https://hooks.slack.com/services/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 fi + - step: + name: Promote to Production + script: + - git config --global user.email "ci-bot@jamkazam.com" + - git config --global user.name "CI Bot" + - git fetch origin main:main + - git checkout main + - git merge $BITBUCKET_COMMIT + - git push origin main custom: build-and-push-coturn-dns: - variables: @@ -219,4 +235,4 @@ pipelines: - | if [ $BITBUCKET_EXIT_CODE -ne 0 ]; then curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"🚨 Pipeline Failed: Staging verification/tests failed for commit $BITBUCKET_COMMIT. \"}" https://hooks.slack.com/services/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 - fi \ No newline at end of file + fi diff --git a/scripts/verify-deployment.sh b/scripts/verify-deployment.sh index 3abb78d..2490cf0 100644 --- a/scripts/verify-deployment.sh +++ b/scripts/verify-deployment.sh @@ -3,7 +3,12 @@ set -e COMMIT_HASH=$1 ENV=$2 # staging or production -SLACK_WEBHOOK_URL="https://hooks.slack.com/services/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" + +if [ "$ENV" == "production" ]; then + SLACK_WEBHOOK_URL="https://hooks.slack.com/services/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" +else + SLACK_WEBHOOK_URL="https://hooks.slack.com/services/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" +fi if [ -z "$COMMIT_HASH" ]; then echo "Usage: $0 "