From c022e926d0c80692822217b737a23813690b17c7 Mon Sep 17 00:00:00 2001 From: tkdwns414 Date: Sun, 24 Dec 2023 23:59:54 +0900 Subject: [PATCH 1/4] [feat] create ci.yml --- .github/workflows/ci.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 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..40b474c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,29 @@ +name: CI + +on: + pull_request: + branches: [ "develop" ] + +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'corretto' + + - name: create secret config file + run: | + cd src/main/resources + echo "${{ secrets.APPLICATION }}" > ./application-secret.properties + + - name: build with gradle + run: | + chmod +x gradlew + ./gradlew clean build -x test From 9109b9147502ba5e399068d057add7ce6f0fb9c8 Mon Sep 17 00:00:00 2001 From: tkdwns414 Date: Sun, 24 Dec 2023 23:59:58 +0900 Subject: [PATCH 2/4] [feat] create cd.yml --- .github/workflows/cd.yml | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..ad7972a --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,61 @@ +name: CI + +on: + pull_request: + branches: [ "develop" ] + +jobs: + CI: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'corretto' + + - name: create secret config file + run: | + cd src/main/resources + echo "${{ secrets.APPLICATION }}" > ./application-secret.properties + + - name: build with gradle + run: | + chmod +x gradlew + ./gradlew clean build -x test + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2.9.1 + + - name: Login to Docker Hub + uses: docker/login-action@v2.2.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }} + + CD: + needs: [CI] + runs-on: ubuntu-22.04 + + steps: + - name: Docker Image Pull and Container Run + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.RELEASE_SERVER_HOST }} + username: ${{ secrets.RELEASE_SERVER_USERNAME }} + key: ${{ secrets.RELEASE_SERVER_KEY }} + script: | + cd ~ + ./deploy.sh \ No newline at end of file From 3c1e1ec021d496359558f61d1538f2991ab32358 Mon Sep 17 00:00:00 2001 From: tkdwns414 Date: Mon, 25 Dec 2023 00:16:28 +0900 Subject: [PATCH 3/4] [feat] create Dockerfile --- Dockerfile | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..fa698d1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM gradle:8.5-jdk17 AS builder +COPY . /usr/src +WORKDIR /usr/src +RUN gradle wrapper --gradle-version 8.5 +RUN ./gradlew clean build -x test + +FROM openjdk:17-jdk-alpine +COPY --from=builder /usr/src/build/libs/pingleserver-0.0.1-SNAPSHOT.jar /usr/app/app.jar +ENTRYPOINT ["java", "-jar", "/usr/app/app.jar"] \ No newline at end of file From 66b5c37196b8520ae3f6e4fa5b703c52a8227755 Mon Sep 17 00:00:00 2001 From: tkdwns414 Date: Mon, 25 Dec 2023 00:16:49 +0900 Subject: [PATCH 4/4] [feat] edit cd.yml --- .github/workflows/cd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index ad7972a..7c6d14f 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,7 +1,7 @@ -name: CI +name: CD on: - pull_request: + push: branches: [ "develop" ] jobs: