update-emqx-docs.yaml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. name: Update emqx/emqx-docs
  2. on:
  3. push:
  4. tags:
  5. - 'v*'
  6. workflow_dispatch:
  7. inputs:
  8. tag:
  9. required: true
  10. type: string
  11. permissions:
  12. contents: read
  13. jobs:
  14. update_emqx_docs:
  15. runs-on: ${{ endsWith(github.repository, '/emqx') && 'ubuntu-22.04' || fromJSON('["self-hosted","ephemeral","linux","x64"]') }}
  16. env:
  17. TAG: ${{ github.event_name == 'push' && github.ref_name || github.event.inputs.tag }}
  18. steps:
  19. - name: Generate GitHub App token
  20. id: app-token
  21. uses: actions/create-github-app-token@v1
  22. with:
  23. app-id: ${{ vars.AUTH_APP_ID }}
  24. private-key: ${{ secrets.AUTH_APP_PRIVATE_KEY }}
  25. owner: ${{ github.repository_owner }}
  26. - name: Create PR in emqx/emqx-docs
  27. env:
  28. GH_TOKEN: ${{ steps.app-token.outputs.token }}
  29. run: |
  30. 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}
  31. - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
  32. with:
  33. ref: ${{ env.TAG }}
  34. fetch-depth: 0
  35. - name: Detect emqx profile
  36. id: parse-git-ref
  37. run: |
  38. JSON="$(./scripts/parse-git-ref.sh refs/tags/$TAG)"
  39. PROFILE=$(echo "$JSON" | jq -cr '.profile')
  40. echo "profile=$PROFILE" | tee -a $GITHUB_ENV
  41. TAG_PATTERN=$(echo "${TAG:0:1}*")
  42. PREV_TAG=$(git describe --abbrev=0 --tags --match "${TAG_PATTERN}" --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' --exclude '*docker*' HEAD~1)
  43. echo "PREV_TAG=$PREV_TAG" | tee -a $GITHUB_ENV
  44. - name: Generate changelog
  45. run: |
  46. changes_dir=("changes/ce")
  47. if [ "$PROFILE" == "emqx-enterprise" ]; then
  48. changes_dir+=("changes/ee")
  49. fi
  50. while read -r file; do
  51. tar --append --file=changes.tar $file
  52. done < <(git diff --diff-filter=A --name-only "tags/${PREV_TAG}...HEAD" "${changes_dir[@]}")
  53. gzip changes.tar
  54. - name: Upload artifact
  55. uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
  56. with:
  57. name: changes
  58. path: changes.tar.gz
  59. retention-days: 7
  60. - name: Trigger update-changelog workflow in emqx/emqx-docs
  61. env:
  62. GH_TOKEN: ${{ steps.app-token.outputs.token }}
  63. run: |
  64. gh --repo emqx/emqx-docs workflow run update-changelog.yaml -f version=${TAG} -f repository=${GITHUB_REPOSITORY} -f run_id=${GITHUB_RUN_ID}