1616 DOCKER_USER : ${{ secrets.DOCKER_USER }}
1717 DOCKER_PASSWORD : ${{ secrets.DOCKER_PASSWORD }}
1818 IMAGE_NAME : wken5577/test-migrate-server
19-
19+
2020permissions :
2121 contents : read
2222
@@ -26,63 +26,66 @@ jobs:
2626 runs-on : ubuntu-latest
2727
2828 steps :
29- - name : Checkout
30- uses : actions/checkout@v3
31-
32- - name : Set up JDK 11
33- uses : actions/setup-java@v3
34- with :
35- java-version : ' 11'
36- distribution : ' temurin'
37-
38- - name : Make application ymls
39- run : |
40- cd ./src/main/resources
41- echo "${{ secrets.MIGRATE_APPLICATION_YML }}" | base64 -d > application.yml
42- shell : bash
43-
44- - name : Login to Docker Hub
45- uses : docker/login-action@v1
46- with :
29+ - name : Checkout
30+ uses : actions/checkout@v3
31+
32+ - name : Set up JDK 11
33+ uses : actions/setup-java@v3
34+ with :
35+ java-version : ' 11'
36+ distribution : ' temurin'
37+
38+ - name : Make application ymls
39+ run : |
40+ cd ./gg-pingpong-api /src/main/resources
41+ echo "${{ secrets.MIGRATE_APPLICATION_YML }}" | base64 -d > application.yml
42+ shell : bash
43+
44+ - name : Login to Docker Hub
45+ uses : docker/login-action@v1
46+ with :
4747 username : ${{ env.DOCKER_USER }}
4848 password : ${{ env.DOCKER_PASSWORD }}
49-
50- - name : Build with Gradle
51- run : ./gradlew clean test build
52-
53- - name : build new docker image as latest tag
54- run : |
55- docker build -t ${{ env.IMAGE_NAME }}:latest .
56- docker push ${{ env.IMAGE_NAME }}:latest
57-
58- - name : Get Github Actions IP
59- id : ip
60- uses : haythem/public-ip@v1.3
61-
62- - name : AWS Credentials
63- uses : aws-actions/configure-aws-credentials@v2
64- with :
65- aws-access-key-id : ${{ secrets.AWS_TEST_MIGRATE_SECURITY_ACCESS_KEY_ID }}
66- aws-secret-access-key : ${{ secrets.AWS_TEST_MIGRATE_SECURITY_SECRET_KEY }}
67- aws-region : ap-northeast-2
68-
69- - name : Add Github Actions IP to Security group
70- run : |
49+
50+ - name : Test with Gradle
51+ run : ./gradlew clean test
52+
53+ - name : Build with Gradle
54+ run : ./gradlew clean build -x test
55+
56+ - name : build new docker image as latest tag
57+ run : |
58+ docker build -t ${{ env.IMAGE_NAME }}:latest .
59+ docker push ${{ env.IMAGE_NAME }}:latest
60+
61+ - name : Get Github Actions IP
62+ id : ip
63+ uses : haythem/public-ip@v1.3
64+
65+ - name : AWS Credentials
66+ uses : aws-actions/configure-aws-credentials@v2
67+ with :
68+ aws-access-key-id : ${{ secrets.AWS_TEST_MIGRATE_SECURITY_ACCESS_KEY_ID }}
69+ aws-secret-access-key : ${{ secrets.AWS_TEST_MIGRATE_SECURITY_SECRET_KEY }}
70+ aws-region : ap-northeast-2
71+
72+ - name : Add Github Actions IP to Security group
73+ run : |
7174 aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_TEST_MIGRATE_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
7275
73- - name : executing docker-compose up on test server
74- uses : appleboy/ssh-action@master
75- with :
76- host : ${{ secrets.TEST_MIGRATE_SERVER_HOST }}
77- username : ${{ secrets.TEST_MIGRATE_SERVER_USERNAME }}
78- key : ${{ secrets.TEST_MIGRATE_SERVER_PEM }}
79- script : |
80- cd /home/ec2-user/docker
81- docker-compose down tomcat
82- docker rmi ${{ env.IMAGE_NAME }}:latest
83- docker-compose up tomcat -d
84- docker-compose up prometheus -d
85-
86- - name : Remove Github Actions IP From Security Group
87- run : |
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+ run : |
8891 aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_TEST_MIGRATE_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32
0 commit comments