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

ci: add workflow to update emqx-docs

Ivan Dyachkov 1 год назад
Родитель
Сommit
d5752b737d
1 измененных файлов с 79 добавлено и 0 удалено
  1. 79 0
      .github/workflows/update-emqx-docs.yaml

+ 79 - 0
.github/workflows/update-emqx-docs.yaml

@@ -0,0 +1,79 @@
+name: Update emqx/emqx-docs
+on:
+  workflow_call:
+    inputs:
+      tag:
+        required: true
+        type: string
+    secrets:
+      AUTH_APP_PRIVATE_KEY:
+        required: true
+  workflow_dispatch:
+    inputs:
+      tag:
+        required: true
+        type: string
+
+permissions:
+  contents: read
+
+jobs:
+  update_emqx_docs:
+    runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
+    env:
+      TAG: ${{ github.event.inputs.tag }}
+    steps:
+      - name: Generate GitHub App token
+        id: app-token
+        uses: actions/create-github-app-token@v1
+        with:
+          app-id: ${{ vars.AUTH_APP_ID }}
+          private-key: ${{ secrets.AUTH_APP_PRIVATE_KEY }}
+          owner: ${{ github.repository_owner }}
+
+      - name: Create PR in emqx/emqx-docs
+        env:
+          GH_TOKEN: ${{ steps.app-token.outputs.token }}
+        run: |
+          gh --repo emqx/emqx-docs workflow run update-api-and-cfg-manual.yaml -f version=${GITHUB_REF_NAME##[v|e]} -f repository=${GITHUB_REPOSITORY} -f run_id=${GITHUB_RUN_ID}
+
+      - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
+        with:
+          ref: ${{ github.event.inputs.tag }}
+          fetch-depth: 0
+
+      - name: Detect emqx profile
+        id: parse-git-ref
+        run: |
+          JSON="$(./scripts/parse-git-ref.sh refs/tags/$TAG)"
+          PROFILE=$(echo "$JSON" | jq -cr '.profile')
+          echo "profile=$PROFILE" | tee -a $GITHUB_ENV
+          TAG_PATTERN=$(echo "${TAG:0:1}*")
+          PREV_TAG=$(git describe --abbrev=0 --tags --match "${TAG_PATTERN}" --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' --exclude '*docker*' HEAD~1)
+          echo "PREV_TAG=$PREV_TAG" | tee -a $GITHUB_ENV
+
+      - name: Generate changelog
+        run: |
+          changes_dir=("changes/ce")
+          if [ "$PROFILE" == "emqx-enterprise" ]; then
+            changes_dir+=("changes/ee")
+          fi
+
+          while read -r file; do
+             tar --append --file=changes.tar $file
+          done < <(git diff --diff-filter=A --name-only "tags/${PREV_TAG}...HEAD" "${changes_dir[@]}")
+          gzip changes.tar
+
+      - name: Upload artifact
+        uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
+        with:
+          name: changes
+          path: changes.tar.gz
+          retention-days: 7
+          
+      - name: Trigger update-changelog workflow in emqx/emqx-docs
+        env:
+          GH_TOKEN: ${{ steps.app-token.outputs.token }}
+        run: |
+          gh --repo emqx/emqx-docs workflow run update-changelog.yaml -f version=${TAG} -f repository=${GITHUB_REPOSITORY} -f run_id=${GITHUB_RUN_ID}
+