使用Spectaql和GitHub Actions,将GraphQL模式文档发布到GitHub.io上的备忘录

总结

我想用HTML将GraphQL文档制作成易读的形式,并在github.io上进行公开。
这次我针对GraphQL的模式进行了尝试。顺便说一下,我还使得draw.io可以在Actions上生成图像。
我将使用GitHub Actions,在推送至docs分支时更新documents文件夹中的文件,并在更新时进行公开。

源代码

在Github.io上公开

2022年12月3日进行更新

绘图.io

使用drawio-export-action工具进行操作。

GraphQL is a query language for APIs and a runtime for executing queries with your existing data. It provides a more efficient and flexible way to request and manipulate data.

使用SpectaQL。

管道

name: github pages

on:
  push:
    branches:
      - main  # Set a branch name to trigger deployment
    paths:
      - .github/workflows/**
      - docs/** # documentsフォルダ内が更新されたときに実施

jobs:
  deploy:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0 # rlespinasse/drawio-export-action@v2 を使うときに指定が必要

      - name: Create gh-pages-dir
        run: |
          mkdir -p ./docs/publish


+ # draw.io
+      - name: Export draw.io
+        uses: rlespinasse/drawio-export-action@v2
+        with:
+          path: documents/draw.io
+          format: png
+          output: ../../docs/publish/drawio
+          transparent: true
+          action-mode: all

# npm 準備
      - name: Setup Node
        uses: actions/setup-node@v2
        with:
          node-version: '16'


# # REST スキーマ

      - name: OpenAPI Setup
        run: npm ci
        working-directory: ./documents/api-schema

      - name: OpenAPI Make
        run: npm run redoc
        working-directory: ./documents/api-schema


      - name: OpenAPI Move files
        run: |
          mkdir -p ./docs/publish/api-schema
          mv ./documents/api-schema/dist/index.html ./docs/publish/api-schema/


+ # GraphQL スキーマ
+      - name: GraphQL Setup
+        run: npm ci
+        working-directory: ./documents/graphql-schema
+      - name: GraphQL Make
+        run: npm run build
+        working-directory: ./documents/graphql-schema
+      - name: GraphQL Move files
+        run: |
+          mkdir -p ./docs/publish/graphql-schema
+          mv ./documents/graphql-schema/public/* ./docs/publish/graphql-schema/

# markdown to HTML
# Gatsby
      - name: Gatsby Setup
        run: npm ci
        working-directory: ./documents/design

      - name: Gatsby Make
        run: npm run build
        working-directory: ./documents/design

      - name: Gatsby Move files
        run: |
          mkdir -p ./docs/publish
          mv ./documents/design/public ./docs/publish/design
# pandoc

      - uses: docker://pandoc/core:2.9
        with:
          args: >- # allows you to break string into multiple lines
            --standalone
            --output=docs/index.html
            documents/index.md

# デプロイ
      - name: Deploy
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./docs

2022年12月03日增加记录

发生以下错误。将actions/checkout@v2更新为actions/checkout@v3。

Node.js 12 actions are deprecated. For more information see: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/. Please update the following actions to use Node.js 16: actions/checkout@v2

请提供更多的上下文,以便我可以为您提供确切的翻译。

spectaql博客
drawio导出操作
使用GitHub Actions将Open API文档发布到Github Pages的备忘录
使用GitHub Actions将Storybook文档发布到Github Pages,并使用Webpack5进行公开的备忘录

广告
将在 10 秒后关闭
bannerAds