Просмотр исходного кода

add settings for pdf-converter release

Futa Arai 1 год назад
Родитель
Сommit
f14de7137d

+ 140 - 0
.github/workflows/release-pdf-converter.yml

@@ -0,0 +1,140 @@
+name: Release Docker Image for @growi/pdf-converter
+
+on:
+  pull_request:
+    branches:
+      - release/pdf-converter/**
+    types: [closed]
+
+jobs:
+  build-and-push-image:
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v4
+      with:
+        ref: ${{ github.event.pull_request.base.ref }}
+
+    - name: Retrieve information from package.json
+      uses: myrotvorets/info-from-package-json-action@2.0.1
+      id: package-json
+      with:
+        workingDir: apps/pdf-converter
+
+    - name: Docker meta
+      id: meta
+      uses: docker/metadata-action@v4
+      with:
+        # TODO: setup GCP_PRJ_ID_PDF_CONVERTER
+        images: weseek/growi-pdf-converter,asia.gcr.io/${{ secrets.GCP_PRJ_ID_PDF_CONVERTER }}/growi-pdf-converter
+        tags: |
+          type=raw,value=latest
+          type=raw,value=${{ steps.package-json.outputs.packageVersion }}
+
+    - name: Login to docker.io registry
+      run: |
+        echo ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | docker login --username wsmoogle --password-stdin
+
+    - name: Authenticate to Google Cloud for GROWI.cloud
+      uses: google-github-actions/auth@v1
+      with:
+        # TODO: setup GCP_SA_KEY_PDF_CONVERTER
+        credentials_json: '${{ secrets.GCP_SA_KEY_PDF_CONVERTER }}'
+
+    - name: Setup gcloud
+      uses: google-github-actions/setup-gcloud@v2
+
+    - name: Configure docker for gcloud
+      run: |
+        gcloud auth configure-docker --quiet
+
+    - name: Set up Docker Buildx
+      uses: docker/setup-buildx-action@v3
+
+    - name: Build and push
+      uses: docker/build-push-action@v4
+      with:
+        context: .
+        file: ./apps/pdf-converter/docker/Dockerfile
+        platforms: linux/amd64
+        push: true
+        builder: ${{ steps.buildx.outputs.name }}
+        cache-from: type=gha
+        cache-to: type=gha,mode=max
+        tags: ${{ steps.meta.outputs.tags }}
+
+    - name: Move cache
+      run: |
+        rm -rf /tmp/.buildx-cache
+        mv /tmp/.buildx-cache-new /tmp/.buildx-cache
+
+    - name: Add tag
+      uses: anothrNick/github-tag-action@v1
+      env:
+        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        CUSTOM_TAG: v${{ steps.package-json.outputs.packageVersion }}
+        VERBOSE : true
+
+    - name: Update Docker Hub Description
+      uses: peter-evans/dockerhub-description@v3
+      with:
+        username: wsmoogle
+        password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
+        repository: weseek/growi-slackbot-proxy
+        # TODO: create pdf-converter README
+        readme-filepath: ./apps/pdf-converter/docker/README.md
+
+
+  create-pr-for-next-rc:
+    needs: build-and-push-image
+
+    runs-on: ubuntu-latest
+
+    strategy:
+      matrix:
+        node-version: [20.x]
+
+    steps:
+    - uses: actions/checkout@v4
+      with:
+        ref: ${{ github.event.pull_request.base.ref }}
+
+    - uses: pnpm/action-setup@v4
+
+    - uses: actions/setup-node@v4
+      with:
+        node-version: ${{ matrix.node-version }}
+        cache: 'pnpm'
+
+    - name: Install dependencies
+      run: |
+        pnpm add turbo --global
+        pnpm install --frozen-lockfile
+
+    - name: Bump versions for next RC
+      run: |
+        turbo run version:prerelease --filter=@growi/pdf-converter
+
+    - name: Retrieve information from package.json
+      uses: myrotvorets/info-from-package-json-action@2.0.1
+      id: package-json
+      with:
+        workingDir: apps/pdf-converter
+
+    - name: Commit
+      uses: github-actions-x/commit@v2.9
+      with:
+        github-token: ${{ secrets.GITHUB_TOKEN }}
+        push-branch: support/prepare-v${{ steps.package-json.outputs.packageVersion }}
+        commit-message: 'Bump version'
+        name: GitHub Action
+
+    - name: Create PR
+      uses: repo-sync/pull-request@v2
+      with:
+        source_branch: support/prepare-v${{ steps.package-json.outputs.packageVersion }}
+        destination_branch: master
+        pr_title: Prepare v${{ steps.package-json.outputs.packageVersion }}
+        pr_label: flag/exclude-from-changelog,type/prepare-next-version
+        pr_body: "An automated PR generated by ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
+        github_token: ${{ secrets.GITHUB_TOKEN }}

+ 1 - 0
.github/workflows/release.yml

@@ -174,6 +174,7 @@ jobs:
         pnpm install --frozen-lockfile
         pnpm install --frozen-lockfile
 
 
     - name: Bump versions for next RC
     - name: Bump versions for next RC
+      # TODO: check if prepatch for pdf-converter is necessary
       run: |
       run: |
         turbo run version:prepatch --filter=@growi/app
         turbo run version:prepatch --filter=@growi/app
         turbo run version:prepatch --filter=@growi/slackbot-proxy
         turbo run version:prepatch --filter=@growi/slackbot-proxy

+ 3 - 1
apps/pdf-converter/package.json

@@ -13,7 +13,9 @@
     "start:prod": "node dist/index.js",
     "start:prod": "node dist/index.js",
     "lint": "pnpm eslint **/*.{js,ts}",
     "lint": "pnpm eslint **/*.{js,ts}",
     "gen:swagger-spec": "SWAGGER_GENERATION=true node --import @swc-node/register/esm-register src/bin/index.ts generate-swagger --output ./specs",
     "gen:swagger-spec": "SWAGGER_GENERATION=true node --import @swc-node/register/esm-register src/bin/index.ts generate-swagger --output ./specs",
-    "build": "pnpm tsc -p tsconfig.build.json"
+    "build": "pnpm tsc -p tsconfig.build.json",
+    "version:prerelease": "pnpm version prerelease --preid=pdf-converter",
+    "version:prepatch": "pnpm version prepatch --preid=pdf-converter"
   },
   },
   "dependencies": {
   "dependencies": {
     "@godaddy/terminus": "^4.12.1",
     "@godaddy/terminus": "^4.12.1",

+ 6 - 0
apps/pdf-converter/turbo.json

@@ -16,6 +16,12 @@
     "build": {
     "build": {
       "outputs": ["dist/**"],
       "outputs": ["dist/**"],
       "outputLogs": "new-only"
       "outputLogs": "new-only"
+    },
+    "version:prerelease": {
+      "cache": false
+    },
+    "version:prepatch": {
+      "cache": false
     }
     }
   }
   }
 }
 }