Skip to content

Add blue-green deployment scripts and API for deployment info#51

Merged
subsub97 merged 2 commits intomainfrom
chore/blue-green-yml
Apr 20, 2026
Merged

Add blue-green deployment scripts and API for deployment info#51
subsub97 merged 2 commits intomainfrom
chore/blue-green-yml

Conversation

@subsub97
Copy link
Copy Markdown
Collaborator

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:

  • Refactored the deploy-main.yml workflow to implement blue-green deployments by running a new deploy.sh script, adding concurrency control to prevent overlapping deployments, and enhancing deployment verification steps. [1] [2] [3]
  • Added 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:

  • Introduced a new rollback.yml workflow for manual rollbacks, which uses a dedicated scripts/rollback.sh script to redeploy a specified or previous successful Docker image, leveraging the same safety checks as standard deployments. [1] [2]

Deployment Status API:

  • Added DeployInfoController and DeployInfoResponse to provide a /api/v1/deploy-info endpoint that returns the current deployed version, color, and uptime, supporting blue-green verification and smoke testing. [1] [2]

Configuration Changes:

  • Updated application.yml to include app.version and app.deploy-color properties, sourced from environment variables for accurate deployment metadata reporting.

Copilot AI review requested due to automatic review settings April 20, 2026 12:49
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 20, 2026

Test Results

53 tests   53 ✅  0s ⏱️
 6 suites   0 💤
 6 files     0 ❌

Results for commit 3df62bc.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.sh scripts to manage blue-green switching, health checks, smoke tests, and rollback.
  • Adds /api/v1/deploy-info API 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 thread scripts/deploy.sh
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 thread scripts/deploy.sh
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 thread scripts/deploy.sh Outdated
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 }}"

@subsub97 subsub97 merged commit f4064b8 into main Apr 20, 2026
3 checks passed
@subsub97 subsub97 deleted the chore/blue-green-yml branch April 20, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants