@@ -58,34 +58,35 @@ jobs:
5858 docker build -t ${{ env.IMAGE_NAME }}:latest .
5959 docker push ${{ env.IMAGE_NAME }}:latest
6060
61- - name : Get Github Actions IP
62- id : ip
63- 64-
65- - name : AWS Credentials
61+ - name : Create the configuration file
62+ run : |
63+ cat << EOF > config.json
64+ {
65+ "AutoScalingGroupName": "gg-dev",
66+ "DesiredConfiguration": {
67+ "LaunchTemplate": {
68+ "LaunchTemplateId": "${{ secrets.DEV_LAUNCH_TEMPLATE_ID }}",
69+ "Version": "\$Latest"
70+ }
71+ },
72+ "Preferences": {
73+ "MinHealthyPercentage": 100,
74+ "MaxHealthyPercentage": 110,
75+ "InstanceWarmup": 300,
76+ "ScaleInProtectedInstances": "Ignore",
77+ "StandbyInstances": "Ignore"
78+ }
79+ }
80+ EOF
81+ cat config.json
82+
83+ - name : Configure AWS CLI
6684 uses : aws-actions/configure-aws-credentials@v2
6785 with :
6886 aws-access-key-id : ${{ secrets.AWS_TEST_MIGRATE_SECURITY_ACCESS_KEY_ID }}
6987 aws-secret-access-key : ${{ secrets.AWS_TEST_MIGRATE_SECURITY_SECRET_KEY }}
7088 aws-region : ap-northeast-2
7189
72- - name : Add Github Actions IP to Security group
73- run : |
74- aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_TEST_MIGRATE_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
75-
76- - name : executing docker-compose up on test server
77- uses : appleboy/ssh-action@master
78- with :
79- host : ${{ secrets.TEST_MIGRATE_SERVER_HOST }}
80- username : ${{ secrets.TEST_MIGRATE_SERVER_USERNAME }}
81- key : ${{ secrets.TEST_MIGRATE_SERVER_PEM }}
82- script : |
83- cd /home/ec2-user/docker
84- docker-compose down tomcat
85- docker rmi ${{ env.IMAGE_NAME }}:latest
86- docker-compose up tomcat -d
87- docker-compose up prometheus -d
88-
89- - name : Remove Github Actions IP From Security Group
90+ - name : Trigger Instance Refresh
9091 run : |
91- aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_TEST_MIGRATE_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
92+ aws autoscaling start-instance-refresh --cli-input-json file://config.json
0 commit comments