update-emqx-docs.yaml 2.7 KB

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