From 70a0ee471f5727be303332bdcaca7ddd6067409c Mon Sep 17 00:00:00 2001 From: Son Gahyun <77109954+hyun2371@users.noreply.github.com> Date: Thu, 1 Aug 2024 16:28:45 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20:=20ssh=20action=20=EC=88=98=ED=96=89?= =?UTF-8?q?=20=EC=8B=9C=20key=EB=A1=9C=20=EC=9D=B8=EC=A6=9D=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD=20(#12)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 691a2023..6c5bc3d5 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -8,10 +8,11 @@ permissions: contents: read jobs: - build: + build-and-push-image: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v3 # 자바 버전 설정 - name: Set up JDK 17 @@ -24,7 +25,7 @@ jobs: - name: Generate application.yml run: | mkdir -p ./src/main/resources - echo "${{ secrets.APPLICATION_CORE }}" | base64 -d > ./src/main/resources/application.yml + echo "${{ secrets.APPLICATION_YML }}" | base64 -d > ./src/main/resources/application.yml # gradle 권한 부여 - name: Grant execute permission for gradlew @@ -46,7 +47,6 @@ jobs: - name: Build with Gradle run: ./gradlew build -x test - # 도커 허브 로그인 - name: Docker Hub Login uses: docker/login-action@v2 @@ -54,20 +54,23 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - # 도커 이미지 빌드 및 푸시 - name: docker image build and push run: | docker build -f Dockerfile -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_APP_NAME }} . docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_APP_NAME }} + deploy: + needs: build-and-push-image + runs-on: ubuntu-latest + steps: # 서버 백그라운드 실행 - name: pull image and run container uses: appleboy/ssh-action@master with: host: ${{ secrets.EC2_HOST }} username: ${{ secrets.EC2_USERNAME }} - password: ${{ secrets.EC2_PASSWORD }} + key: ${{ secrets.EC2_KEY }} port: ${{ secrets.EC2_PORT }} script: | cd compose