[FEAT] Circuit breaker 구현 #36
This file contains hidden or 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
| name: Java CI with Gradle | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| # 실행 권한 추가 | |
| - name: Set executable permission for gradlew | |
| run: chmod +x ./gradlew | |
| # Spring Boot 어플리케이션 Build (1) | |
| - name: Spring Boot Build | |
| run: ./gradlew clean build --exclude-task test | |
| # Docker 이미지 Build (2) | |
| - name: docker image build | |
| run: docker build -t lehojun/mayi . | |
| # DockerHub Login (3) | |
| - name: docker login | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| # Docker Hub push (4) | |
| - name: docker Hub push | |
| run: docker push lehojun/mayi | |
| # GET GitHub IP (5) | |
| - name: get GitHub IP | |
| id: ip | |
| uses: haythem/public-ip@v1.2 | |
| # Configure AWS Credentials (6) - AWS 접근 권한 취득(IAM) | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ap-northeast-2 | |
| # Add github ip to AWS (7) | |
| - name: Add GitHub IP to AWS | |
| run: | | |
| aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 | |
| # AWS EC2 Server Connect & Docker 명령어 실행 (8) | |
| - name: AWS EC2 Connection | |
| uses: appleboy/ssh-action@v0.1.6 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.EC2_PASSWORD }} | |
| port: ${{ secrets.EC2_SSH_PORT }} | |
| timeout: 60s | |
| script: | | |
| cd /home/ubuntu | |
| sudo docker-compose down | |
| sudo docker-compose up -d | |
| sudo docker pull lehojun/mayi | |
| sudo docker-compose up -d --force-recreate | |
| # REMOVE Github IP FROM security group (9) | |
| - name: Remove IP FROM security group | |
| run: | | |
| aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 |