Add blue-green deployment scripts and API for deployment info#51
Merged
Add blue-green deployment scripts and API for deployment info#51
Conversation
Test Results53 tests 53 ✅ 0s ⏱️ Results for commit 3df62bc. ♻️ This comment has been updated with latest results. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a blue-green deployment mechanism for the MOA application (GitHub Actions + server-side scripts) and adds an API endpoint to expose deployment metadata for verification/smoke testing.
Changes:
- Refactors the production deploy workflow to run a new blue-green deployment script with concurrency control.
- Adds
deploy.sh/rollback.shscripts to manage blue-green switching, health checks, smoke tests, and rollback. - Adds
/api/v1/deploy-infoAPI plus config (app.version,app.deploy-color) to report deployed version/color/uptime.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/main/resources/application.yml |
Adds env-driven app version/color config used by deploy-info. |
src/main/kotlin/com/moa/service/dto/DeployInfoResponse.kt |
DTO for deployment metadata (version/color/uptime). |
src/main/kotlin/com/moa/controller/DeployInfoController.kt |
New endpoint to expose deploy metadata for verification. |
scripts/deploy.sh |
Blue-green deploy script (pull, run, health check, Nginx switch, smoke test, cleanup). |
scripts/rollback.sh |
Rollback wrapper script that redeploys a prior/specified tag via deploy.sh. |
.github/workflows/deploy-main.yml |
Uses deploy.sh on self-hosted runner with concurrency. |
.github/workflows/rollback.yml |
Adds manual rollback workflow using rollback.sh with concurrency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+33
to
+43
| if [ -f "$STATE_FILE" ] && [ "$(cat "$STATE_FILE")" = "blue" ]; then | ||
| CURRENT="blue" | ||
| NEXT="green" | ||
| CURRENT_PORT=8080 | ||
| NEXT_PORT=8081 | ||
| else | ||
| CURRENT="green" | ||
| NEXT="blue" | ||
| CURRENT_PORT=8081 | ||
| NEXT_PORT=8080 | ||
| fi |
Comment on lines
+12
to
+16
| APP_DIR="/home/ubuntu/app" | ||
| STATE_FILE="${APP_DIR}/active-color" | ||
| DEPLOY_HISTORY="${APP_DIR}/deploy-history" | ||
| NGINX_UPSTREAM_CONF="/etc/nginx/conf.d/moa-upstream.conf" | ||
| LOCK_FILE="${APP_DIR}/deploy.lock" |
Comment on lines
+17
to
+18
| SMOKE_TEST_HOST="moa-official.kr" | ||
| HEALTH_CHECK_MAX_RETRY=30 |
Comment on lines
+90
to
+96
| - name: Run Blue-Green Deploy | ||
| env: | ||
| DOCKER_IMAGE: godqhr721/moa_server | ||
| run: | | ||
| if sudo docker inspect moa-server &>/dev/null; then | ||
| sudo docker stop moa-server || true | ||
| sudo docker rm -f moa-server || true | ||
| sudo docker image prune -af || true | ||
| fi | ||
|
|
||
| sudo docker pull godqhr721/moa_server:${{ needs.setup.outputs.docker_tag }} | ||
|
|
||
| - name: Run container | ||
| chmod +x scripts/deploy.sh | ||
| sudo -E bash scripts/deploy.sh "${{ needs.setup.outputs.docker_tag }}" | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a robust blue-green deployment system with health checks, smoke tests, and rollback support for the MOA application. It adds a new deployment workflow, a manual rollback workflow, and supporting scripts, as well as an API endpoint to expose deployment status for verification. The changes significantly improve deployment safety, enable zero-downtime releases, and provide easy rollback in case of failure.
Deployment Automation & Blue-Green Strategy:
deploy-main.ymlworkflow to implement blue-green deployments by running a newdeploy.shscript, adding concurrency control to prevent overlapping deployments, and enhancing deployment verification steps. [1] [2] [3]scripts/deploy.sh, a comprehensive blue-green deployment script that handles container management, health checks, Nginx upstream switching, smoke tests, graceful shutdowns, and deployment history logging.Rollback Support:
rollback.ymlworkflow for manual rollbacks, which uses a dedicatedscripts/rollback.shscript to redeploy a specified or previous successful Docker image, leveraging the same safety checks as standard deployments. [1] [2]Deployment Status API:
DeployInfoControllerandDeployInfoResponseto provide a/api/v1/deploy-infoendpoint that returns the current deployed version, color, and uptime, supporting blue-green verification and smoke testing. [1] [2]Configuration Changes:
application.ymlto includeapp.versionandapp.deploy-colorproperties, sourced from environment variables for accurate deployment metadata reporting.