From 0a8a82a8ae70f33e6da90101711d62ec81021329 Mon Sep 17 00:00:00 2001 From: Yun-Changseop Date: Mon, 18 Dec 2023 15:18:09 +0900 Subject: [PATCH] =?UTF-8?q?[Feat]=20Actions=EB=A1=9C=20=EB=B0=B0=ED=8F=AC?= =?UTF-8?q?=EB=A5=BC=20=EC=A0=81=EC=9A=A9=ED=95=9C=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 49 ++++++++++++++++++++++++++++++ src/main/resources/application.yml | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..552245d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,49 @@ +name: deploy-actions + +on: + push: + branches: [prod] + +jobs: + ci: + runs-on: ubuntu-20.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.GIT_TOKEN }} + submodules: true + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and Push Docker images + run: | + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }} . + docker push {{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPOSITORY }}:latest + + + cd: + needs: [ci] + runs-on: ubuntu-20.04 + + steps: + - name: Docker Image Pull And Container Run + uses: appleboy/ssh-action@v1.0.0 + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + port: ${{ secrets.PORT }} + script: | + docker compose down + docker system prune -a + docker compose pull + docker compose up -d \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 28b53ff..ff4253d 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,4 +1,4 @@ -spring.profiles.default: local +spring.profiles.default: prod ---