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

Merge pull request #9540 from weseek/feat/155548-157823-pdf-converter-release-ci

add settings for pdf-converter release
Yuki Takei 1 год назад
Родитель
Сommit
26b6ba6200

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

@@ -0,0 +1,125 @@
+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:
+        images: growilabs/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: 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: growilabs/pdf-converter
+        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 }}

+ 4 - 0
apps/pdf-converter/README.md

@@ -27,6 +27,10 @@ This app (PDF-Converter) is necessary to convert markdown pages to PDF during th
 1. Request PDF bulk export from the page menu in the GROWI app
     - It might take a few minutes, depending on GROWI's configurations
 
+### Note
+When creating both containers from scratch or rebuilding them, **make sure to select and create GROWI-Dev first**.  
+This is necessary because GROWI-Dev uses devcontainer features for enabling node, and [features is only enabled for the first container created](https://github.com/devcontainers/spec/issues/546).
+
 ## PDF-Converter client library
 [pdf-converter-client](../../packages/pdf-converter-client) is a client library for requesting PDF-Converter, and is used by GROWI internally. It's code is auto-generated from the PDF-Converter code.
 

+ 4 - 0
apps/pdf-converter/README_JP.md

@@ -27,6 +27,10 @@ GROWI には、ページを PDF 形式で一括エクスポートする機能が
 1. GROWI アプリのページメニューから PDF の一括エクスポートをリクエスト
    - GROWI の設定によっては、処理に数分かかる場合があります
 
+### 備考
+二つのコンテナを初めて作成する時や、コンテナを rebuild する時、**必ず GROWI-Dev を先に選択して作成してください**。  
+GROWI-Dev は devcontainer features を使用して node を有効化していますが、[features は最初に作成したコンテナにしか有効になりません](https://github.com/devcontainers/spec/issues/546)。
+
 ## PDF-Converter クライアントライブラリ
 [pdf-converter-client](../../packages/pdf-converter-client) は、PDF-Converter へのリクエストを行うクライアントライブラリであり、GROWI 内部で使用されています。このコードは PDF-Converter のコードから自動生成されます。
 

+ 32 - 0
apps/pdf-converter/docker/README.md

@@ -0,0 +1,32 @@
+
+GROWI PDF Converter Official docker image
+==============================================
+
+[![Node CI for pdf-converter](https://github.com/weseek/growi/actions/workflows/ci-pdf-converter.yml/badge.svg)](https://github.com/weseek/growi/actions/workflows/ci-pdf-converter.yml) [![docker-pulls](https://img.shields.io/docker/pulls/growilabs/pdf-converter.svg)](https://hub.docker.com/r/growilabs/pdf-converter/)
+
+
+Supported tags and respective Dockerfile links
+------------------------------------------------
+
+* [`1.0.0`, `latest` (Dockerfile)](https://github.com/weseek/growi/blob/master/apps/pdf-converter/docker/Dockerfile)
+
+
+What is GROWI PDF Converter used for?
+---------------------------------------
+
+GROWI provides a feature that bulk exports pages in PDF format.
+PDF Converter is necessary to convert markdown pages to PDF during that process.
+
+
+Usage
+-----
+
+```bash
+docker run -d growilabs/pdf-converter
+```
+
+and go to `http://localhost:3010/` .
+
+### docker-compose
+
+PDF Converter is configured by default in [weseek/growi-docker-compose](https://github.com/weseek/growi-docker-compose). GROWI will be able to request to PDF Converter after `docker-compose up`.

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

@@ -13,7 +13,9 @@
     "start:prod": "node dist/index.js",
     "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",
-    "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": {
     "@godaddy/terminus": "^4.12.1",

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

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