docs: add new config doc for authorization (include_mountpoint) #2024
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Docs | |
| on: | |
| push: | |
| tags: | |
| - v* | |
| pull_request: | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| versions: ${{ steps.set_environment.outputs.versions }} | |
| docs_types: ${{ steps.set_environment.outputs.docs_types }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: set_environment | |
| id: set_environment | |
| run: | | |
| if [ "${{ github.event_name }}" = "push" ]; then | |
| current_branch=$(echo ${{ github.ref_name }}) | |
| current_version=$(echo ${{ github.ref_name }} | sed -r "s/^(.*)-.*$/\1/") | |
| current_version=${current_version/e/v} | |
| else | |
| current_version=$(echo "$GITHUB_BASE_REF" | cut -d- -f 2) | |
| current_version="v${current_version}" | |
| fi | |
| tag_list=$(git tag | egrep "^v.*$" | xargs echo -n) | |
| docs_types='["emqx"]' | |
| latest_version=$(python3 .github/scripts/generate_version.py $tag_list | jq -r '.[0]') | |
| if [[ $current_version == $latest_version ]]; | |
| then | |
| build_version_list='["'latest'","'$current_version'"]' | |
| else | |
| build_version_list='["'$current_version'"]' | |
| fi | |
| echo "versions=$build_version_list" >> $GITHUB_OUTPUT | |
| echo "docs_types=$docs_types" >> $GITHUB_OUTPUT | |
| deploy: | |
| needs: prepare | |
| strategy: | |
| matrix: | |
| version: ${{ fromJSON(needs.prepare.outputs.versions) }} | |
| docs_type: ${{ fromJSON(needs.prepare.outputs.docs_types) }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: clone docs | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| path: docs-files | |
| - name: set env | |
| run: | | |
| echo "DOCS_TYPE=${{ matrix.docs_type }}" >> $GITHUB_ENV | |
| echo "DOCS_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV | |
| echo "VERSION=${{ matrix.version }}" >> $GITHUB_ENV | |
| - name: Generate GitHub App token | |
| id: app-token | |
| uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 | |
| with: | |
| app-id: ${{ vars.AUTH_APP_ID }} | |
| private-key: ${{ secrets.AUTH_APP_PRIVATE_KEY }} | |
| owner: ${{ github.repository_owner }} | |
| - name: clone frontend | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| repository: 'emqx/docs-emqx-com-frontend' | |
| ref: next | |
| token: ${{ steps.app-token.outputs.token }} | |
| path: frontend | |
| - name: use python | |
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | |
| with: | |
| python-version: '3.10' | |
| - name: use node.js | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
| with: | |
| node-version-file: 'frontend/.nvmrc' | |
| - name: enable corepack | |
| run: corepack enable | |
| - name: use pnpm | |
| uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 | |
| with: | |
| version: 8 | |
| - name: generate directory.json | |
| run: | | |
| cd docs-files | |
| pip3 install pyyaml | |
| ./gen.py ce | tee directory.json | |
| python3 .github/scripts/remove_unused.py directory.json $(pwd) | |
| - name: set current emqx version | |
| run: | | |
| cd docs-files | |
| source current-version.env | |
| find ./en_US ./zh_CN ./ja_JP -type f -name "*.md" -exec sed -i 's/@CE_VERSION@/'"$CE_VERSION"'/g' {} + | |
| find ./en_US ./zh_CN ./ja_JP -type f -name "*.md" -exec sed -i 's/@EE_VERSION@/'"$EE_VERSION"'/g' {} + | |
| find ./en_US ./zh_CN ./ja_JP -type f -name "*.md" -exec sed -i 's/@CE_MINOR_VERSION@/'"$CE_MINOR_VERSION"'/g' {} + | |
| find ./en_US ./zh_CN ./ja_JP -type f -name "*.md" -exec sed -i 's/@EE_MINOR_VERSION@/'"$EE_MINOR_VERSION"'/g' {} + | |
| - name: move files | |
| run: | | |
| rm frontend/docs/en/index.md || true | |
| rm frontend/docs/zh/index.md || true | |
| rm frontend/docs/ja/index.md || true | |
| rm frontend/docs/*.md || true | |
| rm frontend/README.md || true | |
| mkdir -p frontend/docs/en/${DOCS_TYPE}/${VERSION}/ | |
| mkdir -p frontend/docs/zh/${DOCS_TYPE}/${VERSION}/ | |
| mkdir -p frontend/docs/ja/${DOCS_TYPE}/${VERSION}/ | |
| mkdir -p frontend/docs/public/api/ | |
| mkdir -p frontend/redoc/ | |
| cp -r docs-files/en_US/* frontend/docs/en/${DOCS_TYPE}/${VERSION}/ | |
| cp -r docs-files/zh_CN/* frontend/docs/zh/${DOCS_TYPE}/${VERSION}/ | |
| cp -r docs-files/ja_JP/* frontend/docs/ja/${DOCS_TYPE}/${VERSION}/ | |
| cp -r docs-files/redocly/*.json frontend/redoc/ || true | |
| cp docs-files/directory.json frontend/docs/.vitepress/config/directory.json | |
| cp docs-files/directory.json frontend/docs/public/api/${DOCS_TYPE}_${VERSION}_directory.json | |
| - name: generate version config | |
| run: | | |
| cd docs-files | |
| version_list=$(git tag | egrep "^v.*$" | xargs echo -n) | |
| python3 .github/scripts/generate_version.py $version_list > ../frontend/docs/public/api/${DOCS_TYPE}_versions.json | |
| - name: setup hocon | |
| if: matrix.version != 'latest' | |
| run: | | |
| echo "HOCON=true" >> $GITHUB_ENV | |
| cp -r docs-files/hocon/*.json frontend/docs/public/api/ | |
| for file in frontend/docs/public/api/hocon-ce-*-en.json; do | |
| version=$(echo $file | sed -E 's_.*/hocon-ce-(.*)-en.json_\1_g') | |
| cp $file frontend/docs/public/api/hocon-ce-${version}-ja.json | |
| done | |
| for file in frontend/docs/public/api/hocon-ee-*-en.json; do | |
| version=$(echo $file | sed -E 's_.*/hocon-ee-(.*)-en.json_\1_g') | |
| cp $file frontend/docs/public/api/hocon-ee-${version}-ja.json | |
| done | |
| hocon_products=(enterprise) | |
| for hocon_product in "${hocon_products[@]}"; do | |
| online_versions=$(curl -s https://docs.emqx.com/api/${hocon_product}_hocon_versions.json) | |
| if [ $? -eq 0 ]; then | |
| online_versions=$(echo $online_versions | jq -r '.'[]) | |
| else | |
| online_versions="" | |
| fi | |
| if [[ $hocon_product == "emqx" ]]; then | |
| local_versions=$(ls frontend/docs/public/api/hocon-ce-*-*on | sed -E 's_.*/hocon-ce-(.*)-(en|zh|ja).json_\1_g' | uniq) | |
| else | |
| local_versions=$(ls frontend/docs/public/api/hocon-ee-*-*on | sed -E 's_.*/hocon-ee-(.*)-(en|zh|ja).json_\1_g' | uniq) | |
| fi | |
| all_versions=$(echo -e "$online_versions\n$local_versions" | sort -u | awk NF | uniq) | |
| all_versions=$(echo "$all_versions" | sort -rV) | |
| jq -nR '[inputs]' <<< "$all_versions" > frontend/docs/public/api/${hocon_product}_hocon_versions.json | |
| cat frontend/docs/public/api/${hocon_product}_hocon_versions.json | |
| done | |
| - name: build docs | |
| run: | | |
| cd frontend | |
| export NODE_OPTIONS=--max_old_space_size=12288 | |
| pnpm install | |
| pnpm build | |
| - name: build redoc | |
| if: matrix.version != 'latest' | |
| run: | | |
| cd frontend | |
| LANGS=(zh en ja) | |
| if [ ! -f "redoc/ee-ja.json" ]; then | |
| cp redoc/ee-en.json redoc/ee-ja.json | |
| fi | |
| for lang in "${LANGS[@]}"; do | |
| pnpm redocly build-docs redoc/ee-${lang}.json -t redoc/template-emqx-enterprise.hbs \ | |
| --output docs/.vitepress/dist/${lang}/enterprise/${VERSION}/admin/api-docs.html \ | |
| --config=redoc/redocly.yaml \ | |
| --templateOptions.title "EMQX Enterprise ${VERSION} API Documentation" \ | |
| --templateOptions.headerTitle "EMQX Enterprise ${VERSION} API Documentation" \ | |
| --templateOptions.description "EMQX Enterprise ${VERSION} API Documentation" \ | |
| --templateOptions.version "${VERSION}" \ | |
| $(if [ "${lang}" == "zh" ]; then echo "--templateOptions.langZH \"zh\""; fi) \ | |
| $(if [ "${lang}" == "ja" ]; then echo "--templateOptions.langJA \"ja\""; fi) | |
| done | |
| - name: set aws credentials | |
| if: github.event_name == 'push' | |
| uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4.3.1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_DEFAULT_REGION }} | |
| - name: upload files to aws s3 | |
| if: github.event_name == 'push' | |
| run: | | |
| aws s3 rm --recursive s3://docs-emqx-com/zh/${DOCS_TYPE}/${VERSION} || true | |
| aws s3 rm --recursive s3://docs-emqx-com/en/${DOCS_TYPE}/${VERSION} || true | |
| aws s3 rm --recursive s3://docs-emqx-com/ja/${DOCS_TYPE}/${VERSION} || true | |
| aws s3 cp --recursive frontend/docs/.vitepress/dist/ s3://docs-emqx-com/ | |
| aws cloudfront create-invalidation --distribution-id ${{ secrets.AWS_DOCS_CLOUDFRONT_ID }} --paths "/zh/emqx/*" "/en/emqx/*" "/ja/emqx/*" "/zh/enterprise/*" "/en/enterprise/*" "/api/*" "/sitemap_${DOCS_TYPE}_${VERSION}.xml" | |
| - name: upload files to tencent cos | |
| if: github.event_name == 'push' | |
| run: | | |
| pip3 install coscmd | |
| coscmd config -a ${{ secrets.TENCENT_COS_ID }} -s ${{ secrets.TENCENT_COS_KEY }} -b docs-1302406139 -r ap-shanghai | |
| coscmd delete -r -f en/${DOCS_TYPE}/${VERSION} || true | |
| coscmd delete -r -f zh/${DOCS_TYPE}/${VERSION} || true | |
| coscmd delete -r -f ja/${DOCS_TYPE}/${VERSION} || true | |
| coscmd config -a ${{ secrets.TENCENT_COS_ID }} -s ${{ secrets.TENCENT_COS_KEY }} -b docs-1302406139 -e cos.accelerate.myqcloud.com | |
| coscmd upload -r frontend/docs/.vitepress/dist/ / | |
| - name: set tccli | |
| if: github.event_name == 'push' | |
| run: | | |
| pip3 install tccli | |
| tccli configure set secretId ${{ secrets.TENCENT_COS_ID }} | |
| tccli configure set secretKey ${{ secrets.TENCENT_COS_KEY }} | |
| tccli configure set region ap-shanghai | |
| - name: flush cdn | |
| if: github.event_name == 'push' | |
| run: | | |
| tccli cdn PurgePathCache --cli-unfold-argument --Paths https://docs.emqx.com/zh/emqx/ https://docs.emqx.com/en/emqx/ https://docs.emqx.com/ja/emqx/ https://docs.emqx.com/zh/enterprise/ https://docs.emqx.com/en/enterprise/ https://docs.emqx.com/api/ --FlushType delete | |
| tccli cdn PurgeUrlsCache --cli-unfold-argument --Urls https://docs.emqx.com/sitemap_${DOCS_TYPE}_${VERSION}.xml | |
| - name: update search index | |
| if: github.event_name == 'push' | |
| uses: Swilder-M/docsearch-scraper-simple@next | |
| env: | |
| APPLICATION_ID: ${{ secrets.ALGOLIA_APPLICATION_ID_NEXT }} | |
| API_KEY: ${{ secrets.ALGOLIA_API_KEY_NEXT }} | |
| with: | |
| docs_type: ${{ env.DOCS_TYPE }} | |
| docs_version: ${{ env.VERSION }} |