From 413b796bb0d4e9cf087b7a0fd45b0e294ec0dcb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EB=8F=84=EC=97=B0?= Date: Mon, 26 Aug 2024 21:16:33 +0900 Subject: [PATCH] =?UTF-8?q?CI-CD=20=ED=8C=8C=EC=9D=B4=ED=94=84=EB=9D=BC?= =?UTF-8?q?=EC=9D=B8=20=EA=B0=9C=EC=84=A0=20(#148)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat[api-server]: swagger 업로드 파이프라인 추가 * fix[api-server]: swagger 배포를 분리 * style[api-server]: 변경사항 테스트 --- .github/workflows/api-lottery-ci.yml | 12 +++++ .github/workflows/api-lottery-deploy.yml | 19 ------- .github/workflows/api-order-ci.yml | 12 +++++ .github/workflows/api-order-deploy.yml | 19 ------- .github/workflows/swagger.yml | 54 +++++++++++++++++++ .../java/com/watermelon/server/S3Config.java | 1 + 6 files changed, 79 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/swagger.yml diff --git a/.github/workflows/api-lottery-ci.yml b/.github/workflows/api-lottery-ci.yml index dd6ecca6..c2b398b5 100644 --- a/.github/workflows/api-lottery-ci.yml +++ b/.github/workflows/api-lottery-ci.yml @@ -54,6 +54,18 @@ jobs: run: | ./gradlew --info lottery:test + - name: List files to be uploaded + run: | + echo "Files in lottery/build/generated-snippets/:" + ls -la lottery/build/generated-snippets/ + + # 스웨거 소스 업로드 + - name: Upload multiple files as an artifact + uses: actions/upload-artifact@v3 + with: + name: lottery-snippets + path: lottery/build/generated-snippets/* + # 테스트 후 Result를 보기위해 Publish Unit Test Results step 추가 - name: Publish Unit Test Results uses: EnricoMi/publish-unit-test-result-action@v1 diff --git a/.github/workflows/api-lottery-deploy.yml b/.github/workflows/api-lottery-deploy.yml index d830f8e8..9a2c772e 100644 --- a/.github/workflows/api-lottery-deploy.yml +++ b/.github/workflows/api-lottery-deploy.yml @@ -70,25 +70,6 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - # 테스트 후 스웨어 문서를 생성한다. - - name: Generate Swagger Document - run: | - ./gradlew --info test - ./gradlew mergeApiSpecs - ./gradlew openapi3 - ./gradlew customGenerateSwaggerUI - ls - - # 스웨거를 업로드한다. - - name: Upload to S3 - uses: jakejarvis/s3-sync-action@master - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }} - AWS_REGION: 'ap-northeast-2' # 리전 정보 - SOURCE_DIR: 'swagger-ui-watermelon' # 업로드할 파일들이 위치한 로컬 디렉토리 - AWS_S3_BUCKET: 'watermelon-s3-bucket' # S3 버킷 이름 - # 애플리케이션을 Build 한다. - name: 🔧 Build Spring server run: | diff --git a/.github/workflows/api-order-ci.yml b/.github/workflows/api-order-ci.yml index 56a31d63..1cf3096c 100644 --- a/.github/workflows/api-order-ci.yml +++ b/.github/workflows/api-order-ci.yml @@ -53,6 +53,18 @@ jobs: - name: Test run: ./gradlew --info order:test + - name: List files to be uploaded + run: | + echo "Files in order/build/generated-snippets/:" + ls -la order/build/generated-snippets/ + + # 스웨거 소스 업로드 + - name: Upload multiple files as an artifact + uses: actions/upload-artifact@v3 + with: + name: order-snippets + path: order/build/generated-snippets/* + # 테스트 후 Result를 보기위해 Publish Unit Test Results step 추가 - name: Publish Unit Test Results uses: EnricoMi/publish-unit-test-result-action@v1 diff --git a/.github/workflows/api-order-deploy.yml b/.github/workflows/api-order-deploy.yml index 2f839361..9a0be67c 100644 --- a/.github/workflows/api-order-deploy.yml +++ b/.github/workflows/api-order-deploy.yml @@ -70,25 +70,6 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - # 테스트 후 스웨어 문서를 생성한다. - - name: Generate Swagger Document - run: | - ./gradlew --info test - ./gradlew mergeApiSpecs - ./gradlew openapi3 - ./gradlew customGenerateSwaggerUI - ls - - # 스웨거를 업로드한다. - - name: Upload to S3 - uses: jakejarvis/s3-sync-action@master - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }} - AWS_REGION: 'ap-northeast-2' # 리전 정보 - SOURCE_DIR: 'swagger-ui-watermelon' # 업로드할 파일들이 위치한 로컬 디렉토리 - AWS_S3_BUCKET: 'watermelon-s3-bucket' # S3 버킷 이름 - # 애플리케이션을 Build 한다. - name: 🔧 Build Spring server run: | diff --git a/.github/workflows/swagger.yml b/.github/workflows/swagger.yml new file mode 100644 index 00000000..d3f94335 --- /dev/null +++ b/.github/workflows/swagger.yml @@ -0,0 +1,54 @@ +name: Order-Deploy + +on: + pull_request: + branches: + - deploy + types: + - closed + paths: + - "lottery/**" + - "order/**" + - "common/**" + +jobs: + test: + runs-on: ubuntu-latest + + steps: + + # 스니펫을 불러온다. + - name: Download multiple files as an artifact + uses: actions/download-artifact@v3 + with: + name: order-snippets + path: order/build/generated-snippets/ + + - name: Download multiple files as an artifact + uses: actions/download-artifact@v3 + with: + name: lottery-snippets + path: lottery/build/generated-snippets/ + + - name: Verify files downloaded + run: | + echo "Download Files" + ls -la order/build/generated-snippets/ + ls -la lottery/build/generated-snippets/ + + - name: Generate Swagger Document + run: | + ./gradlew mergeApiSpecs + ./gradlew openapi3 + ./gradlew customGenerateSwaggerUI + ls + + # 스웨거를 업로드한다. + - name: Upload to S3 + uses: jakejarvis/s3-sync-action@master + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }} + AWS_REGION: 'ap-northeast-2' # 리전 정보 + SOURCE_DIR: 'swagger-ui-watermelon' # 업로드할 파일들이 위치한 로컬 디렉토리 + AWS_S3_BUCKET: 'watermelon-s3-bucket' # S3 버킷 이름 \ No newline at end of file diff --git a/common/src/main/java/com/watermelon/server/S3Config.java b/common/src/main/java/com/watermelon/server/S3Config.java index 290b74be..9fe8c38f 100644 --- a/common/src/main/java/com/watermelon/server/S3Config.java +++ b/common/src/main/java/com/watermelon/server/S3Config.java @@ -29,4 +29,5 @@ public AmazonS3 amazonS3() { .withRegion(region) .build(); } + }