-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
더 정확하게
- Loading branch information
Showing
1 changed file
with
13 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,10 @@ on: | |
branches: | ||
- develop | ||
- feat/96-feature-bluegreen | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
@@ -32,7 +32,7 @@ jobs: | |
- name: Decode env.properties from GitHub Secrets | ||
run: | | ||
echo "${{ secrets.ENV_FILE }}" | base64 --decode > ./env.properties | ||
- name: Decode Firebase config from GitHub Secrets | ||
run: | | ||
echo "${{ secrets.FIREBASE_CONFIG }}" | base64 --decode > ./splanet-firebase.json | ||
|
@@ -67,11 +67,11 @@ jobs: | |
key: ${{ secrets.EC2_SSH_KEY }} | ||
script: | | ||
if sudo docker ps --filter "name=splanet_blue" --format "{{.Names}}" | grep -q "splanet_blue"; then | ||
echo "::set-output name=version::blue" | ||
echo "CURRENT_VERSION=blue" >> $GITHUB_ENV | ||
elif sudo docker ps --filter "name=splanet_green" --format "{{.Names}}" | grep -q "splanet_green"; then | ||
echo "::set-output name=version::green" | ||
echo "CURRENT_VERSION=green" >> $GITHUB_ENV | ||
else | ||
echo "::set-output name=version::none" | ||
echo "CURRENT_VERSION=none" >> $GITHUB_ENV | ||
fi | ||
- name: Deploy New Version to EC2 | ||
|
@@ -81,7 +81,7 @@ jobs: | |
username: ubuntu | ||
key: ${{ secrets.EC2_SSH_KEY }} | ||
script: | | ||
if [ "${steps.current_version.outputs.version}" == "blue" ]; then | ||
if [ "${{ env.CURRENT_VERSION }}" == "blue" ]; then | ||
NEW_VERSION="green" | ||
NEW_PORT=8081 | ||
else | ||
|
@@ -102,12 +102,12 @@ jobs: | |
username: ubuntu | ||
key: ${{ secrets.EC2_SSH_KEY }} | ||
script: | | ||
if [ "${steps.current_version.outputs.version}" == "blue" ]; then | ||
if [ "${{ env.CURRENT_VERSION }}" == "blue" ]; then | ||
NEW_PORT=8081 | ||
else | ||
NEW_PORT=8080 | ||
fi | ||
echo "Waiting for the application to be healthy on http://api.splanet.co.kr:${NEW_PORT}/actuator/health..." | ||
for i in {1..30}; do | ||
if curl -s http://api.splanet.co.kr:${NEW_PORT}/actuator/health | grep '"status":"UP"' > /dev/null; then | ||
|
@@ -117,8 +117,7 @@ jobs: | |
echo "Waiting for application to start... (Attempt $i)" | ||
sleep 5 | ||
done | ||
# If the application is not healthy after 40 attempts (200 seconds), fail the deployment | ||
if [ "$i" -eq 30 ]; then | ||
echo "Application did not start successfully within the expected time." | ||
sudo docker logs splanet_${NEW_VERSION} | ||
|
@@ -132,7 +131,7 @@ jobs: | |
username: ubuntu | ||
key: ${{ secrets.EC2_SSH_KEY }} | ||
script: | | ||
if [ "${{ steps.current_version.outputs.version }}" == "blue" ]; then | ||
if [ "${{ env.CURRENT_VERSION }}" == "blue" ]; then | ||
TARGET_GROUP_ARN="arn:aws:elasticloadbalancing:ap-northeast-2:${{ secrets.AWS_ACCOUNT_ID }}:targetgroup/splanet-8081/${{ secrets.ARN_ID_8081 }}" | ||
else | ||
TARGET_GROUP_ARN="arn:aws:elasticloadbalancing:ap-northeast-2:${{ secrets.AWS_ACCOUNT_ID }}:targetgroup/splanet/${{ secrets.ARN_ID_8080 }}" | ||
|
@@ -147,12 +146,11 @@ jobs: | |
username: ubuntu | ||
key: ${{ secrets.EC2_SSH_KEY }} | ||
script: | | ||
if [ "${{ steps.current_version.outputs.version }}" != "none" ]; then | ||
sudo docker stop splanet_${{ steps.current_version.outputs.version }} | ||
sudo docker rm splanet_${{ steps.current_version.outputs.version }} | ||
if [ "${{ env.CURRENT_VERSION }}" != "none" ]; then | ||
sudo docker stop splanet_${{ env.CURRENT_VERSION }} | ||
sudo docker rm splanet_${{ env.CURRENT_VERSION }} | ||
fi | ||
- name: Clean up old Docker images | ||
uses: appleboy/[email protected] | ||
with: | ||
|