From 611d6fd701e108c43a2b74ec7cfe12ba9ba3795e Mon Sep 17 00:00:00 2001 From: yudonggeun Date: Wed, 11 Dec 2024 16:41:27 +0900 Subject: [PATCH 1/8] =?UTF-8?q?chore=20:=20ci=20workflow=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - server microservice를 위한 배포 잡을 분리합니다. - 특정 버전으로 롤백할 수 있도록 지원합니다. - 자동으로 실행되지 않고 수동으로 실행합니다. --- .github/workflows/ci/server.yml | 78 +++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/ci/server.yml diff --git a/.github/workflows/ci/server.yml b/.github/workflows/ci/server.yml new file mode 100644 index 00000000..faf4c286 --- /dev/null +++ b/.github/workflows/ci/server.yml @@ -0,0 +1,78 @@ +name: Server micro service CI + +on: + workflow_dispatch: + inputs: + version: + description: '배포하고자 하는 버전을 입력해주세요. 최신 버전이라면 생략해주세요. (git commit id 앞 8자리)' + default: 'latest' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - if: github.event.inputs.version != 'latest' + name: checkout + run: git checkout ${{ github.event.inputs.version }} + + - name: set up jdk 21 + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '21' + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: make api documents + run: ./gradlew --info server:openapi3 + + - name: configure openapi3 spec + run: | + yq eval -i '.components.securitySchemes.bearerAuth.type = "http"' ./server/src/main/resources/static/openapi3.yaml + yq eval -i '.components.securitySchemes.bearerAuth.scheme = "bearer"' ./server/src/main/resources/static/openapi3.yaml + yq eval -i '.components.securitySchemes.bearerAuth.bearerFormat = "JWT"' ./server/src/main/resources/static/openapi3.yaml + yq eval -i '.security[0].bearerAuth = []' ./server/src/main/resources/static/openapi3.yaml + + - name: push image using jib + run: ./gradlew --info jib + + tagging: + needs: + - build + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - name: set tag + run: | + echo "IMAGE_TAG=$(git rev-parse --short=8 HEAD)" >> $GITHUB_ENV + + - name: checkout infra repository + uses: actions/checkout@v4 + with: + repository: kSideProject/kpring-infra + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + ref: main + + - name: edit infra repository image tag + run: | + echo 'env(IMAGE_TAG)' + yq eval -i '.service.tag = env(IMAGE_TAG)' ./charts/server/values.yaml + + - name: commit + uses: leigholiver/commit-with-deploy-key@v1.0.4 + with: + source: . + destination_repo: kSideProject/kpring-infra + deploy_key: ${{ secrets.SSH_PRIVATE_KEY }} + commit_message: 'ci: update server image' From 059a601844d364a8feebaaaf7d603990396f05d0 Mon Sep 17 00:00:00 2001 From: yudonggeun Date: Wed, 11 Dec 2024 16:46:51 +0900 Subject: [PATCH 2/8] =?UTF-8?q?chore=20:=20ci=20workflow=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - user microservice를 위한 배포 잡을 분리합니다. - 특정 버전으로 롤백할 수 있도록 지원합니다. - 자동으로 실행되지 않고 수동으로 실행합니다. --- .github/workflows/ci/user.yml | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/ci/user.yml diff --git a/.github/workflows/ci/user.yml b/.github/workflows/ci/user.yml new file mode 100644 index 00000000..3f620481 --- /dev/null +++ b/.github/workflows/ci/user.yml @@ -0,0 +1,82 @@ +name: User micro service CI + +on: + workflow_dispatch: + inputs: + version: + description: '배포하고자 하는 버전을 입력해주세요. 최신 버전이라면 생략해주세요. (git commit id 앞 8자리)' + default: 'latest' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - if: github.event.inputs.version != 'latest' + name: checkout + run: git checkout ${{ github.event.inputs.version }} + + - name: set up jdk 21 + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '21' + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: make api documents + run: ./gradlew --info user:openapi3 + + - name: configure openapi3 spec + run: | + yq eval -i '.components.securitySchemes.bearerAuth.type = "http"' ./user/src/main/resources/static/openapi3.yaml + yq eval -i '.components.securitySchemes.bearerAuth.scheme = "bearer"' ./user/src/main/resources/static/openapi3.yaml + yq eval -i '.components.securitySchemes.bearerAuth.bearerFormat = "JWT"' ./user/src/main/resources/static/openapi3.yaml + yq eval -i '.security[0].bearerAuth = []' ./user/src/main/resources/static/openapi3.yaml + + - name: push image using jib + run: ./gradlew --info jib + + tagging: + needs: + - build + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - if: github.event.inputs.version != 'latest' + name: checkout + run: git checkout ${{ github.event.inputs.version }} + + - name: set image tag + run: | + echo "IMAGE_TAG=$(git rev-parse --short=8 HEAD)" >> $GITHUB_ENV + + - name: checkout infra repository + uses: actions/checkout@v4 + with: + repository: kSideProject/kpring-infra + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + ref: main + + - name: edit infra repository image tag + run: | + echo 'env(IMAGE_TAG)' + yq eval -i '.service.tag = env(IMAGE_TAG)' ./charts/user/values.yaml + + - name: commit + uses: leigholiver/commit-with-deploy-key@v1.0.4 + with: + source: . + destination_repo: kSideProject/kpring-infra + deploy_key: ${{ secrets.SSH_PRIVATE_KEY }} + commit_message: 'ci: update user image version=${{ github.event.inputs.version }}' From 9a8f2d30b668950ef959490f3b448b3415adaaac Mon Sep 17 00:00:00 2001 From: yudonggeun Date: Wed, 11 Dec 2024 16:52:12 +0900 Subject: [PATCH 3/8] =?UTF-8?q?chore=20:=20ci=20workflow=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - auth microservice를 위한 배포 잡을 분리합니다. - 특정 버전으로 롤백할 수 있도록 지원합니다. - 자동으로 실행되지 않고 수동으로 실행합니다. --- .github/workflows/ci/auth.yml | 82 +++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 .github/workflows/ci/auth.yml diff --git a/.github/workflows/ci/auth.yml b/.github/workflows/ci/auth.yml new file mode 100644 index 00000000..c6c14f47 --- /dev/null +++ b/.github/workflows/ci/auth.yml @@ -0,0 +1,82 @@ +name: Auth micro service CI + +on: + workflow_dispatch: + inputs: + version: + description: '배포하고자 하는 버전을 입력해주세요. 최신 버전이라면 생략해주세요. (git commit id 앞 8자리)' + default: 'latest' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - if: github.event.inputs.version != 'latest' + name: checkout + run: git checkout ${{ github.event.inputs.version }} + + - name: set up jdk 21 + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: '21' + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: make api documents + run: ./gradlew --info auth:openapi3 + + - name: configure openapi3 spec + run: | + yq eval -i '.components.securitySchemes.bearerAuth.type = "http"' ./auth/src/main/resources/static/openapi3.yaml + yq eval -i '.components.securitySchemes.bearerAuth.scheme = "bearer"' ./auth/src/main/resources/static/openapi3.yaml + yq eval -i '.components.securitySchemes.bearerAuth.bearerFormat = "JWT"' ./auth/src/main/resources/static/openapi3.yaml + yq eval -i '.security[0].bearerAuth = []' ./auth/src/main/resources/static/openapi3.yaml + + - name: push image using jib + run: ./gradlew --info auth:jib + + tagging: + needs: + - build + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - if: github.event.inputs.version != 'latest' + name: checkout + run: git checkout ${{ github.event.inputs.version }} + + - name: set image tag + run: | + echo "IMAGE_TAG=$(git rev-parse --short=8 HEAD)" >> $GITHUB_ENV + + - name: checkout infra repository + uses: actions/checkout@v4 + with: + repository: kSideProject/kpring-infra + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + ref: main + + - name: edit infra repository image tag + run: | + echo 'env(IMAGE_TAG)' + yq eval -i '.service.tag = env(IMAGE_TAG)' ./charts/auth/values.yaml + + - name: commit + uses: leigholiver/commit-with-deploy-key@v1.0.4 + with: + source: . + destination_repo: kSideProject/kpring-infra + deploy_key: ${{ secrets.SSH_PRIVATE_KEY }} + commit_message: 'ci: update auth image version=${{ github.event.inputs.version }}' From 0442175e18a9dfb3a6ffcaeaed23724e83462cfa Mon Sep 17 00:00:00 2001 From: yudonggeun Date: Wed, 11 Dec 2024 16:54:47 +0900 Subject: [PATCH 4/8] =?UTF-8?q?fix=20:=20server=20ci=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI 작업 이후 배포 이미지 버전 명시 오류 수정 --- .github/workflows/ci/server.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci/server.yml b/.github/workflows/ci/server.yml index faf4c286..4db97772 100644 --- a/.github/workflows/ci/server.yml +++ b/.github/workflows/ci/server.yml @@ -43,7 +43,7 @@ jobs: yq eval -i '.security[0].bearerAuth = []' ./server/src/main/resources/static/openapi3.yaml - name: push image using jib - run: ./gradlew --info jib + run: ./gradlew --info server:jib tagging: needs: @@ -53,7 +53,11 @@ jobs: - name: checkout uses: actions/checkout@v4 - - name: set tag + - if: github.event.inputs.version != 'latest' + name: checkout + run: git checkout ${{ github.event.inputs.version }} + + - name: set image tag run: | echo "IMAGE_TAG=$(git rev-parse --short=8 HEAD)" >> $GITHUB_ENV @@ -75,4 +79,4 @@ jobs: source: . destination_repo: kSideProject/kpring-infra deploy_key: ${{ secrets.SSH_PRIVATE_KEY }} - commit_message: 'ci: update server image' + commit_message: 'ci: update server image version=${{ github.event.inputs.version }}' From e402e65de2e77c46251fb761cddd4ec9be2f6945 Mon Sep 17 00:00:00 2001 From: yudonggeun Date: Wed, 11 Dec 2024 16:55:36 +0900 Subject: [PATCH 5/8] =?UTF-8?q?fix=20:=20user=20ci=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 컨테이너 이미지 갱신시 user 서비스만 갱신되도록 변경 --- .github/workflows/ci/user.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci/user.yml b/.github/workflows/ci/user.yml index 3f620481..bba695ce 100644 --- a/.github/workflows/ci/user.yml +++ b/.github/workflows/ci/user.yml @@ -43,7 +43,7 @@ jobs: yq eval -i '.security[0].bearerAuth = []' ./user/src/main/resources/static/openapi3.yaml - name: push image using jib - run: ./gradlew --info jib + run: ./gradlew --info user:jib tagging: needs: From fd06d6ab5f3dff6c9b4472fe0f8af36763029dee Mon Sep 17 00:00:00 2001 From: yudonggeun Date: Wed, 11 Dec 2024 16:56:05 +0900 Subject: [PATCH 6/8] =?UTF-8?q?chore=20:=20=ED=86=B5=ED=95=A9=20ci=20workf?= =?UTF-8?q?low=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 83 ---------------------------------------- 1 file changed, 83 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index e90b7e08..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: CI - -on: - push: - branches: [ main ] # push 되었을 때, 실행 - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: set up jdk 21 - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: '21' - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: make api documents - run: ./gradlew --info openapi3 - - - name: configure openapi3 spec - run: | - yq eval -i '.components.securitySchemes.bearerAuth.type = "http"' ./server/src/main/resources/static/openapi3.yaml - yq eval -i '.components.securitySchemes.bearerAuth.scheme = "bearer"' ./server/src/main/resources/static/openapi3.yaml - yq eval -i '.components.securitySchemes.bearerAuth.bearerFormat = "JWT"' ./server/src/main/resources/static/openapi3.yaml - yq eval -i '.security[0].bearerAuth = []' ./server/src/main/resources/static/openapi3.yaml - - yq eval -i '.components.securitySchemes.bearerAuth.type = "http"' ./user/src/main/resources/static/openapi3.yaml - yq eval -i '.components.securitySchemes.bearerAuth.scheme = "bearer"' ./user/src/main/resources/static/openapi3.yaml - yq eval -i '.components.securitySchemes.bearerAuth.bearerFormat = "JWT"' ./user/src/main/resources/static/openapi3.yaml - yq eval -i '.security[0].bearerAuth = []' ./user/src/main/resources/static/openapi3.yaml - - yq eval -i '.components.securitySchemes.bearerAuth.type = "http"' ./auth/src/main/resources/static/openapi3.yaml - yq eval -i '.components.securitySchemes.bearerAuth.scheme = "bearer"' ./auth/src/main/resources/static/openapi3.yaml - yq eval -i '.components.securitySchemes.bearerAuth.bearerFormat = "JWT"' ./auth/src/main/resources/static/openapi3.yaml - yq eval -i '.security[0].bearerAuth = []' ./auth/src/main/resources/static/openapi3.yaml - - - name: push image using jib - run: ./gradlew --info jib - - tagging: - needs: - - build - runs-on: ubuntu-latest - steps: - - name: checkout - uses: actions/checkout@v4 - - - name: set tag - run: | - echo "IMAGE_TAG=$(git rev-parse --short=8 HEAD)" >> $GITHUB_ENV - - - name: checkout infra repository - uses: actions/checkout@v4 - with: - repository: kSideProject/kpring-infra - ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} - ref: main - - - name: edit infra repository tag - run: | - echo 'env(IMAGE_TAG)' - yq eval -i '.service.tag = env(IMAGE_TAG)' ./charts/server/values.yaml - yq eval -i '.service.tag = env(IMAGE_TAG)' ./charts/user/values.yaml - yq eval -i '.service.tag = env(IMAGE_TAG)' ./charts/auth/values.yaml - - - name: commit - uses: leigholiver/commit-with-deploy-key@v1.0.4 - with: - source: . - destination_repo: kSideProject/kpring-infra - deploy_key: ${{ secrets.SSH_PRIVATE_KEY }} - commit_message: 'ci: update tag to env(IMAGE_TAG)' From f0cab5ea933dc41fcef5febf773944e468e5f16d Mon Sep 17 00:00:00 2001 From: yudonggeun Date: Wed, 11 Dec 2024 17:36:33 +0900 Subject: [PATCH 7/8] =?UTF-8?q?fix=20:=20=EC=B5=9C=EC=8B=A0=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=EC=9D=B8=20=EA=B2=BD=EC=9A=B0=EC=97=90=EB=A7=8C=20bui?= =?UTF-8?q?ld=20=EC=8B=A4=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci/auth.yml | 2 +- .github/workflows/ci/server.yml | 2 +- .github/workflows/ci/user.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci/auth.yml b/.github/workflows/ci/auth.yml index c6c14f47..c5af030a 100644 --- a/.github/workflows/ci/auth.yml +++ b/.github/workflows/ci/auth.yml @@ -9,11 +9,11 @@ on: jobs: build: + if: github.event.inputs.version == 'latest' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - if: github.event.inputs.version != 'latest' name: checkout run: git checkout ${{ github.event.inputs.version }} diff --git a/.github/workflows/ci/server.yml b/.github/workflows/ci/server.yml index 4db97772..00d2349e 100644 --- a/.github/workflows/ci/server.yml +++ b/.github/workflows/ci/server.yml @@ -9,11 +9,11 @@ on: jobs: build: + if: github.event.inputs.version == 'latest' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - if: github.event.inputs.version != 'latest' name: checkout run: git checkout ${{ github.event.inputs.version }} diff --git a/.github/workflows/ci/user.yml b/.github/workflows/ci/user.yml index bba695ce..fb43c188 100644 --- a/.github/workflows/ci/user.yml +++ b/.github/workflows/ci/user.yml @@ -9,11 +9,11 @@ on: jobs: build: + if: github.event.inputs.version == 'latest' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - if: github.event.inputs.version != 'latest' name: checkout run: git checkout ${{ github.event.inputs.version }} From fa403835951fcc0b52c1cdb823595cdcb1933951 Mon Sep 17 00:00:00 2001 From: yudonggeun Date: Wed, 11 Dec 2024 17:37:25 +0900 Subject: [PATCH 8/8] =?UTF-8?q?chore=20:=20frontend=20ci=20workflow=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci/front.yml | 70 ++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/ci/front.yml diff --git a/.github/workflows/ci/front.yml b/.github/workflows/ci/front.yml new file mode 100644 index 00000000..82b7fea1 --- /dev/null +++ b/.github/workflows/ci/front.yml @@ -0,0 +1,70 @@ +name: Frontend Nginx micro service CI + +on: + workflow_dispatch: + inputs: + version: + description: '배포하고자 하는 버전을 입력해주세요. 최신 버전이라면 생략해주세요. (git commit id 앞 8자리)' + default: 'latest' + +jobs: + build: + if: github.event.inputs.version == 'latest' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + name: checkout + run: git checkout ${{ github.event.inputs.version }} + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + # Build Docker image + - name: Build Docker Image + run: | + docker build -t kpring/front_app:$(git rev-parse --short=8 HEAD) . + + # Push Docker image to DockerHub + - name: Push Docker Image to DockerHub + run: | + docker push kpring/front_app:$(git rev-parse --short=8 HEAD) + + tagging: + needs: + - build + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + + - if: github.event.inputs.version != 'latest' + name: checkout + run: git checkout ${{ github.event.inputs.version }} + + - name: set image tag + run: | + echo "IMAGE_TAG=$(git rev-parse --short=8 HEAD)" >> $GITHUB_ENV + + - name: checkout infra repository + uses: actions/checkout@v4 + with: + repository: kSideProject/kpring-infra + ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} + ref: main + + - name: edit infra repository image tag + run: | + echo 'env(IMAGE_TAG)' + yq eval -i '.image.tag = env(IMAGE_TAG)' ./charts/front/values.yaml + + - name: commit + uses: leigholiver/commit-with-deploy-key@v1.0.4 + with: + source: . + destination_repo: kSideProject/kpring-infra + deploy_key: ${{ secrets.SSH_PRIVATE_KEY }} + commit_message: 'ci: update frontend image version=${{ github.event.inputs.version }}'