From 4d0a7fe922b700950d39ecee5c3ebb3c4cfd7e69 Mon Sep 17 00:00:00 2001 From: xihxxn Date: Sun, 17 May 2026 15:20:48 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[Chore]=20CI/CD=20GitHub=20Actions=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 64 ++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) 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..87ddcca --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,64 @@ +name: Deploy to EC2 + +on: + push: + branches: [ develop ] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + java-version: '21' + distribution: 'corretto' + + - name: Grant execute permission for gradlew + run: chmod +x backend/gradlew + + - name: Build with Gradle + working-directory: backend + run: ./gradlew bootJar -x test + env: + DB_URL: ${{ secrets.DB_URL }} + DB_USER: ${{ secrets.DB_USER }} + DB_PASSWORD: ${{ secrets.DB_PASSWORD }} + JWT_SECRET: ${{ secrets.JWT_SECRET }} + JWT_EXPIRATION: ${{ secrets.JWT_EXPIRATION }} + + - name: Log in to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Build and push Docker image + working-directory: backend + run: | + docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/piroin-backend:latest . + docker push ${{ secrets.DOCKERHUB_USERNAME }}/piroin-backend:latest + + - name: Deploy to EC2 + uses: appleboy/ssh-action@v1.0.0 + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USER }} + key: ${{ secrets.EC2_SSH_KEY }} + script: | + docker pull ${{ secrets.DOCKERHUB_USERNAME }}/piroin-backend:latest + docker stop piroin-backend || true + docker rm piroin-backend || true + docker run -d \ + --name piroin-backend \ + -p 8080:8080 \ + -e DB_URL=${{ secrets.DB_URL }} \ + -e DB_USER=${{ secrets.DB_USER }} \ + -e DB_PASSWORD=${{ secrets.DB_PASSWORD }} \ + -e JWT_SECRET=${{ secrets.JWT_SECRET }} \ + -e JWT_EXPIRATION=${{ secrets.JWT_EXPIRATION }} \ + ${{ secrets.DOCKERHUB_USERNAME }}/piroin-backend:latest From b257884936ccef0ac39182051741741defe54154 Mon Sep 17 00:00:00 2001 From: xihxxn Date: Sun, 17 May 2026 15:24:52 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[Chore]=20CI=20GitHub=20Actions=20=EB=B9=8C?= =?UTF-8?q?=EB=93=9C=20=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c67ef61 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,32 @@ +name: CI + +on: + pull_request: + branches: [ develop ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up JDK 21 + uses: actions/setup-java@v3 + with: + java-version: '21' + distribution: 'corretto' + + - name: Grant execute permission for gradlew + run: chmod +x backend/gradlew + + - name: Build with Gradle + working-directory: backend + run: ./gradlew bootJar -x test + env: + DB_URL: ${{ secrets.DB_URL }} + DB_USER: ${{ secrets.DB_USER }} + DB_PASSWORD: ${{ secrets.DB_PASSWORD }} + JWT_SECRET: ${{ secrets.JWT_SECRET }} + JWT_EXPIRATION: ${{ secrets.JWT_EXPIRATION }}