-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] 무중단 배포 GitAction 스크립트 업데이트 (#830)
- Loading branch information
Showing
2 changed files
with
48 additions
and
46 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 |
---|---|---|
|
@@ -56,9 +56,27 @@ jobs: | |
docker tag ${{ env.IMAGE_NAME }}:${{ env.VERSION_TAG }} ${{ env.IMAGE_NAME }}:latest | ||
docker push ${{ env.IMAGE_NAME }}:latest | ||
- name: Get Github Actions IP | ||
id: ip | ||
uses: haythem/[email protected] | ||
- name: Create the configuration file | ||
run: | | ||
cat << EOF > config.json | ||
{ | ||
"AutoScalingGroupName": "gg-main", | ||
"DesiredConfiguration": { | ||
"LaunchTemplate": { | ||
"LaunchTemplateId": "${{ secrets.LAUNCH_TEMPLATE_ID }}", | ||
"Version": "\$Latest" | ||
} | ||
}, | ||
"Preferences": { | ||
"MinHealthyPercentage": 100, | ||
"MaxHealthyPercentage": 110, | ||
"InstanceWarmup": 300, | ||
"ScaleInProtectedInstances": "Ignore", | ||
"StandbyInstances": "Ignore" | ||
} | ||
} | ||
EOF | ||
cat config.json | ||
- name: AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
|
@@ -67,23 +85,6 @@ jobs: | |
aws-secret-access-key: ${{ secrets.AWS_SECURITY_SECRET_KEY }} | ||
aws-region: ap-northeast-2 | ||
|
||
- name: Add Github Actions IP to Security group | ||
run: | | ||
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_MAIN_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 | ||
- name: executing docker-compose up on main server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.MAIN_SERVER_HOST }} | ||
username: ${{ secrets.MAIN_SERVER_USERNAME }} | ||
key: ${{ secrets.MAIN_SERVER_PEM }} | ||
script: | | ||
cd ./docker | ||
docker-compose down tomcat | ||
docker rmi ${{ env.IMAGE_NAME }}:latest | ||
docker-compose up tomcat -d | ||
docker-compose up prometheus -d | ||
- name: Remove Github Actions IP From Security Group | ||
- name: Trigger Instance Refresh | ||
run: | | ||
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_MAIN_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 | ||
aws autoscaling start-instance-refresh --cli-input-json file://config.json |
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 |
---|---|---|
|
@@ -58,34 +58,35 @@ jobs: | |
docker build -t ${{ env.IMAGE_NAME }}:latest . | ||
docker push ${{ env.IMAGE_NAME }}:latest | ||
- name: Get Github Actions IP | ||
id: ip | ||
uses: haythem/[email protected] | ||
|
||
- name: AWS Credentials | ||
- name: Create the configuration file | ||
run: | | ||
cat << EOF > config.json | ||
{ | ||
"AutoScalingGroupName": "gg-dev", | ||
"DesiredConfiguration": { | ||
"LaunchTemplate": { | ||
"LaunchTemplateId": "${{ secrets.DEV_LAUNCH_TEMPLATE_ID }}", | ||
"Version": "\$Latest" | ||
} | ||
}, | ||
"Preferences": { | ||
"MinHealthyPercentage": 100, | ||
"MaxHealthyPercentage": 110, | ||
"InstanceWarmup": 300, | ||
"ScaleInProtectedInstances": "Ignore", | ||
"StandbyInstances": "Ignore" | ||
} | ||
} | ||
EOF | ||
cat config.json | ||
- name: Configure AWS CLI | ||
uses: aws-actions/configure-aws-credentials@v2 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_TEST_MIGRATE_SECURITY_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_TEST_MIGRATE_SECURITY_SECRET_KEY }} | ||
aws-region: ap-northeast-2 | ||
|
||
- name: Add Github Actions IP to Security group | ||
run: | | ||
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_TEST_MIGRATE_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 | ||
- name: executing docker-compose up on test server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.TEST_MIGRATE_SERVER_HOST }} | ||
username: ${{ secrets.TEST_MIGRATE_SERVER_USERNAME }} | ||
key: ${{ secrets.TEST_MIGRATE_SERVER_PEM }} | ||
script: | | ||
cd /home/ec2-user/docker | ||
docker-compose down tomcat | ||
docker rmi ${{ env.IMAGE_NAME }}:latest | ||
docker-compose up tomcat -d | ||
docker-compose up prometheus -d | ||
- name: Remove Github Actions IP From Security Group | ||
- name: Trigger Instance Refresh | ||
run: | | ||
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_TEST_MIGRATE_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 | ||
aws autoscaling start-instance-refresh --cli-input-json file://config.json |