From 051a411ee7c401cede66a084f0102da71cc5e8a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=ED=98=B8=EB=B9=88?= Date: Mon, 20 May 2024 18:07:13 +0900 Subject: [PATCH] Update server-cd.yml --- .github/workflows/server-cd.yml | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/.github/workflows/server-cd.yml b/.github/workflows/server-cd.yml index eb24ca0ce..d4dad234d 100644 --- a/.github/workflows/server-cd.yml +++ b/.github/workflows/server-cd.yml @@ -52,20 +52,11 @@ jobs: # 서버에 접속 후 Docker 이미지 가져와서 배포 - name: SSH into Server - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.EC2_HOST }} - username: ${{ secrets.EC2_USERNAME }} - password: ${{ secrets.EC2_PRIVATE_KEY }} - port: 22 - script: | - echo hello - # docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} - # docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:issue-tracker-dev - # 기존에 실행 중인 컨테이너 중지 및 삭제 - # if [ $(docker ps -q -f name=spring-server) ]; then - # docker stop spring-server - # docker rm spring-server - # fi - # 새로운 컨테이너 실행 - # docker run -d --name spring-server ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}:issue-tracker-dev + run: | + echo "$EC2_PRIVATE_KEY" >> $HOME/key.pem + chmod 400 $HOME/key.pem + ssh -i $HOME/key.pem -o StrictHostKeyChecking=no ${EC2_USERNAME}@${EC2_HOST} '~/script.sh' + env: + EC2_USERNAME: ${{ secrets.EC2_USERNAME }} + EC2_HOST: ${{ secrets.EC2_HOST }} + EC2_PRIVATE_KEY: ${{ secrets.EC2_PRIVATE_KEY }}