Skip to content

Merge branch 'chore/#793' of https://github.com/woowacourse-teams/202… #7

Merge branch 'chore/#793' of https://github.com/woowacourse-teams/202…

Merge branch 'chore/#793' of https://github.com/woowacourse-teams/202… #7

name: Rolling Deployment
on:
push:
branches:
- chore/#793
jobs:
deploy-prod1:
name: Deploy to Prod1 Instance
runs-on: runner-prod1
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Prepare Deploy
run: |
cd ~/deploy && ./prepare-deploy.sh
- name: Run Prod1 instance deploy script
run: |
cd ~/deploy && ./deploy.sh
check-prod1:
name: Check Prod1 Instance
runs-on: runner-prod1
needs: deploy-prod1
steps:
- name: Wait for Prod1 instance to be ready
run: sleep 25
- name: Health check for Prod1 instance
run: |
ATTEMPTS=0
MAX_ATTEMPTS=3
until [ $ATTEMPTS -ge $MAX_ATTEMPTS ]; do
RESPONSE=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:8080/health)
if [ $RESPONSE -eq 200 ]; then
echo "Prod1 instance is healthy."
exit 0
fi
echo "Health check failed, attempt $((ATTEMPTS+1))/$MAX_ATTEMPTS. Retrying in 5 seconds..."
ATTEMPTS=$((ATTEMPTS+1))
sleep 5
done
echo "Prod1 instance deployment failed after $MAX_ATTEMPTS attempts."
exit 1
deploy-prod2:
name: Deploy to Prod2 Instance
runs-on: runner-prod2
needs: check-prod1
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Prepare Deploy
run: |
cd ~/deploy && ./prepare-deploy.sh
- name: Run Prod2 instance deploy script
run: |
cd ~/deploy && ./deploy.sh
check-prod2:
name: Check Prod2 Instance
runs-on: runner-prod2
needs: deploy-prod2
steps:
- name: Wait for Prod2 instance to be ready
run: sleep 25
- name: Health check for Prod2 instance
run: |
ATTEMPTS=0
MAX_ATTEMPTS=3
until [ $ATTEMPTS -ge $MAX_ATTEMPTS ]; do
RESPONSE=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:8080/health)
if [ $RESPONSE -eq 200 ]; then
echo "Prod2 instance is healthy."
exit 0
fi
echo "Health check failed, attempt $((ATTEMPTS+1))/$MAX_ATTEMPTS. Retrying in 5 seconds..."
ATTEMPTS=$((ATTEMPTS+1))
sleep 5
done
echo "Prod2 instance deployment failed after $MAX_ATTEMPTS attempts."
exit 1