浏览代码

ci: release workflow to open a PR on docs repo with latest changes

Signed-off-by: CrazyMax <[email protected]>
CrazyMax 3 年之前
父节点
当前提交
0a53d93338
共有 2 个文件被更改,包括 57 次插入0 次删除
  1. 51 0
      .github/workflows/docs.yml
  2. 6 0
      Dockerfile

+ 51 - 0
.github/workflows/docs.yml

@@ -0,0 +1,51 @@
+name: Docs
+
+on:
+  release:
+    types: [published]
+
+jobs:
+  open-pr:
+    runs-on: ubuntu-latest
+    steps:
+      -
+        name: Checkout docs repo
+        uses: actions/checkout@v3
+        with:
+          token: ${{ secrets.GHPAT_DOCS_DISPATCH }}
+          repository: docker/docker.github.io
+          ref: master
+      -
+        name: Prepare
+        run: |
+          rm -rf ./_data/compose-cli/*
+      -
+        name: Build
+        uses: docker/build-push-action@v3
+        with:
+          context: ${{ github.server_url }}/${{ github.repository }}.git#${{ github.event.release.name }}
+          target: docs-reference
+          outputs: ./_data/compose-cli
+      -
+        name: Update compose_version in _config.yml
+        run: |
+          sed -i "s|^compose_version\:.*|compose_version\: \"${{ github.event.release.name }}\"|g" _config.yml
+          cat _config.yml | yq .compose_version
+      -
+        name: Commit changes
+        run: |
+          git add -A .
+      -
+        name: Create PR on docs repo
+        uses: peter-evans/create-pull-request@923ad837f191474af6b1721408744feb989a4c27 # v4.0.4
+        with:
+          token: ${{ secrets.GHPAT_DOCS_DISPATCH }}
+          commit-message: Update Compose reference API to ${{ github.event.release.name }}
+          signoff: true
+          branch: dispatch/compose-api-reference-${{ github.event.release.name }}
+          delete-branch: true
+          title: Update Compose reference API to ${{ github.event.release.name }}
+          body: |
+            Update the Compose reference API documentation to keep in sync with the latest release `${{ github.event.release.name }}`
+          labels: area/Compose
+          draft: false

+ 6 - 0
Dockerfile

@@ -105,3 +105,9 @@ COPY --from=make-go-mod-tidy /compose-cli/go.sum .
 FROM base AS check-go-mod
 COPY . .
 RUN make -f builder.Makefile check-go-mod
+
+# docs-reference is a target used as remote context to update docs on release
+# with latest changes on docker.github.io.
+# see open-pr job in .github/workflows/docs.yml for more details
+FROM scratch AS docs-reference
+COPY docs/reference/*.yaml .