From a69a1d2f5f2337a823f74825c56c3e79d54bab2d Mon Sep 17 00:00:00 2001 From: Sunwoo Jeong <121336359+whispernorbury@users.noreply.github.com> Date: Thu, 4 Apr 2024 14:28:06 +0900 Subject: [PATCH] Create main.yml for git action --- .github/workflows/main.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..dfb284b --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,32 @@ +name: CI/CD for Comkaraka REST API + +on: + push: + branches: + - main + +permissions: read-all + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: checkout repository + uses: actions/checkout@v3 + + - name: compose + uses: appleboy/ssh-action@master + with: + username: ${{ secrets.EC2_USER }} + host: ${{ secrets.EC2_HOST }} + key: ${{ secrets.EC2_SSH_PEM_KEY }} + script: | + cd comkaraka-back + + sudo docker compose down + sudo docker rm $(sudo docker ps -aq) + sudo docker rmi $(sudo docker images -q) + + git pull + sudo docker compose up --build -d