diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml index ded60199..af80743a 100644 --- a/.github/workflows/CD.yml +++ b/.github/workflows/CD.yml @@ -45,26 +45,32 @@ jobs: key: ${{ secrets.EC2_KEY }} script: | - sudo docker kill ${{ secrets.PROJECT_NAME }} - sudo docker rm -f ${{ secrets.PROJECT_NAME }} +# 실행중인 서버 다운 + sudo docker-compose down + +# 백엔드 도커 이미지 삭제 sudo docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }} - sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }} - - sudo docker run \ - -e ADMIN_SECRET_KEY=${{ secrets.ADMIN_SECRET_KEY }} \ - -e AWS_ACCESS_KEY=${{ secrets.AWS_ACCESS_KEY }} \ - -e AWS_SECRET_KEY=${{ secrets.AWS_SECRET_KEY }} \ - -e BASEBALL_API_KEY=${{ secrets.BASEBALL_API_KEY }} \ - -e BASKETBALL_API_KEY=${{ secrets.BASKETBALL_API_KEY }} \ - -e FOOTBALL_API_KEY=${{ secrets.FOOTBALL_API_KEY }} \ - -e GOOGLE_API_KEY=${{ secrets.GOOGLE_API_KEY }} \ - -e GOOGLE_API_SECRET=${{ secrets.GOOGLE_API_SECRET }} \ - -e JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }} \ - -e KAKAO_API_KEY=${{ secrets.KAKAO_API_KEY }} \ - -e NAVER_API_KEY=${{ secrets.NAVER_API_KEY }} \ - -e NAVER_API_SECRET=${{ secrets.NAVER_API_SECRET }} \ - -e RDS_USERNAME=${{ secrets.RDS_USERNAME }} \ - -e RDS_PASSWORD=${{ secrets.RDS_PASSWORD }} \ - -p ${{ secrets.PORT }}:${{ secrets.PORT }} \ - --name ${{ secrets.PROJECT_NAME }} \ - -d ${{ secrets.DOCKERHUB_USERNAME}}/${{ secrets.PROJECT_NAME }} \ No newline at end of file + +# 백엔드 환경변수 파일 삭제 및 생성 + sudo rm .env_b + sudo touch .env_b + +# 백엔드 환경변수 파일 작성 + echo ADMIN_SECRET_KEY=${{ secrets.ADMIN_SECRET_KEY }} >> .env_b + echo AWS_ACCESS_KEY=${{ secrets.AWS_ACCESS_KEY }} >> .env_b + echo AWS_SECRET_KEY=${{ secrets.AWS_SECRET_KEY }} >> .env_b + echo BASEBALL_API_KEY=${{ secrets.BASEBALL_API_KEY }} >> .env_b + echo BASKETBALL_API_KEY=${{ secrets.BASKETBALL_API_KEY }} >> .env_b + echo FOOTBALL_API_KEY=${{ secrets.FOOTBALL_API_KEY }} >> .env_b + echo GOOGLE_API_KEY=${{ secrets.GOOGLE_API_KEY }} >> .env_b + echo GOOGLE_API_SECRET=${{ secrets.GOOGLE_API_SECRET }} >> .env_b + echo JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }} >> .env_b + echo KAKAO_API_KEY=${{ secrets.KAKAO_API_KEY }} >> .env_b + echo NAVER_API_KEY=${{ secrets.NAVER_API_KEY }} >> .env_b + echo NAVER_API_SECRET=${{ secrets.NAVER_API_SECRET }} >> .env_b + echo RDS_USERNAME=${{ secrets.RDS_USERNAME }} >> .env_b + echo RDS_PASSWORD=${{ secrets.RDS_PASSWORD }} >> .env_b + echo ${{ secrets.PORT }}:${{ secrets.PORT }} >> .env_b + +# 백엔드 도커 이미지 pull 및 도커 컴포즈 실행 + sudo docker-compose up -d \ No newline at end of file