From 627c362d8e10aa35d624723d51d0ebaec2c3dbd9 Mon Sep 17 00:00:00 2001 From: yujamint Date: Thu, 27 Jun 2024 09:12:20 +0900 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20submodule=20checkout=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 7e8e473..9693503 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -14,6 +14,9 @@ jobs: steps: - name: 체크아웃 uses: actions/checkout@v4 + with: + submodules: true + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - name: JDK 11 설치 uses: actions/setup-java@v4 From 600e8bbaee2e2e5f2bf22969b8ff71a72e94892e Mon Sep 17 00:00:00 2001 From: yujamint Date: Thu, 27 Jun 2024 23:01:09 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20S3=20+=20CodeDeploy=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=EB=B0=A9=EC=8B=9D=EC=97=90=EC=84=9C=20Docker=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EB=8A=94=20=EA=B2=83=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yaml | 49 ++++++++++++++++------------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 9693503..6e1066f 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -31,33 +31,28 @@ jobs: - name: 빌드 run: ./gradlew build -x test - - name: zip 파일 생성 - run: zip -r ./qtudy.zip . - shell: bash - - - name: AWS credentials 설정 - uses: aws-actions/configure-aws-credentials@v4 + - name: DockerHub 로그인 + uses: docker/login-action@v3 with: - aws-access-key-id: ${{ secrets.STG_AWS_ACCESS_KEY }} - aws-secret-access-key: ${{ secrets.STG_AWS_SECRET_KEY }} - aws-region: ap-northeast-2 - - - name: S3에 zip 파일 업로드 - run: > - aws s3 cp - --region ap-northeast-2 - ./qtudy.zip s3://${{ secrets.STG_AWS_S3_BUCKET_NAME }}/qtudy.zip - - - name: Code Deploy 통해 배포 - run: > - aws deploy create-deployment - --application-name QtudyStageCodeDeploy - --deployment-group-name QtudyStageCodeDeploy-DepGrp - --file-exists-behavior OVERWRITE - --deployment-config-name CodeDeployDefault.AllAtOnce - --s3-location bucket=${{ secrets.STG_AWS_S3_BUCKET_NAME }},bundleType=zip,key=qtudy.zip - --region ap-northeast-2 - - + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Docker 이미지 빌드 & DockerHub에 Push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ secrets.DOCKER_USERNAME }}/qtudy-server:latest + - name: EC2 서버에 배포 + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.STG_SERVER_HOST }} + username: ${{ secrets.STG_SERVER_USERNAME }} + key: ${{ secrets.STG_SERVER_PEM_KEY }} + envs: GITHUB_SHA + script: | + sudo docker stop $(sudo docker ps -a -q) + sudo docker pull ${{secrets.DOCKER_USERNAME}}/qtudy-server + sudo docker run -d -p 8080:8080 --name qtudy-server-container ${{secrets.DOCKER_USERNAME}}/qtudy-server + sudo docker image prune -f