feat: implement token notification #2309
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: TDengine Doc Build and Check | |
| on: | |
| pull_request: | |
| branches: | |
| - 'main' | |
| - '3.0' | |
| - '3.3.6' | |
| - 'docs-cloud' | |
| paths: | |
| - 'docs/**' | |
| - '.github/workflows/tdengine-docs-ci.yml' | |
| - '**/*.md' | |
| env: | |
| DOC_WKC: '/root/doc_ci_work' | |
| ZH_DOC_REPO: 'docs.taosdata.com' | |
| EN_DOC_REPO: 'docs.tdengine.com' | |
| TD_REPO: 'TDengine' | |
| TOOLS_REPO: 'taos-tools' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| check-with-typos: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Actions Repository | |
| uses: actions/checkout@v4 | |
| - name: Use custom zh config file | |
| uses: crate-ci/[email protected] | |
| with: | |
| files: 'docs/zh/' | |
| config: docs/typos.toml | |
| - name: Use custom en config file | |
| uses: crate-ci/[email protected] | |
| with: | |
| files: 'docs/en/' | |
| config: docs/typos.toml | |
| - name: Use custom en config file | |
| uses: crate-ci/[email protected] | |
| with: | |
| files: './*.md' | |
| config: docs/typos.toml | |
| check-with-autocorrect: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: AutoCorrect | |
| id: autocorrect | |
| uses: huacnlee/autocorrect-action@v2 | |
| with: | |
| args: --lint docs/zh/* docs/en/* | |
| continue-on-error: true | |
| - name: Report ReviewDog | |
| if: always() && steps.autocorrect.outcome == 'failure' | |
| uses: tomchon/autocorrect-action@fix/review-dog | |
| env: | |
| REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| reviewdog: true | |
| args: ./docs/zh/* ./docs/en/* **/*.md | |
| - name: Fail if AutoCorrect found issues | |
| if: steps.autocorrect.outcome == 'failure' | |
| run: | | |
| echo "❌ AutoCorrect found formatting issues" | |
| exit 1 | |
| check-with-markdownlint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Detect changed files | |
| uses: tj-actions/changed-files@v46 | |
| id: changed-files | |
| with: | |
| files: | | |
| **/*.md | |
| **/*.mdx | |
| separator: "," | |
| - name: Check with Markdownlint | |
| uses: DavidAnson/markdownlint-cli2-action@v20 | |
| if: steps.changed-files.outputs.any_changed == 'true' | |
| with: | |
| config: 'docs/.markdownlint-cli2.jsonc' | |
| globs: ${{ steps.changed-files.outputs.all_changed_files }} | |
| separator: ',' | |
| build-doc: | |
| runs-on: | |
| group: CI | |
| labels: [self-hosted, doc-build] | |
| needs: | |
| - check-with-typos | |
| - check-with-autocorrect | |
| - check-with-markdownlint | |
| steps: | |
| - name: Get the latest document contents | |
| run: | | |
| set -e | |
| cd ${{ env.DOC_WKC }}/${{ env.TD_REPO }} | |
| git reset --hard | |
| git clean -f | |
| git remote prune origin | |
| git fetch | |
| git checkout ${{ github.event.pull_request.base.ref }} | |
| git pull >/dev/null | |
| git fetch origin +refs/pull/${{ github.event.pull_request.number }}/merge | |
| git checkout -qf FETCH_HEAD | |
| - name: Check document changes | |
| id: changed-doc-files | |
| uses: tj-actions/changed-files@v46 | |
| with: | |
| files: 'docs/**' | |
| path: ${{ env.DOC_WKC }}/${{ env.TD_REPO }} | |
| # settings for pull request event | |
| base_sha: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || '' }} | |
| sha: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} | |
| - name: Check whether the chinese or english docment is built | |
| id: check-doc-lang | |
| env: | |
| ALL_CHANGED_DOCS: ${{ steps.changed-doc-files.outputs.all_changed_files }} | |
| run: | | |
| zh_doc_changed=false | |
| en_doc_changed=false | |
| echo "All changed files: ${{ steps.changed-doc-files.outputs.all_changed_files }}" | |
| echo "Added files: ${{ steps.changed-doc-files.outputs.added_files }}" | |
| echo "Modified files: ${{ steps.changed-doc-files.outputs.modified_files }}" | |
| echo "Deleted files: ${{ steps.changed-doc-files.outputs.deleted_files }}" | |
| for file in $ALL_CHANGED_DOCS; do | |
| case $file in | |
| *docs/zh/*) | |
| zh_doc_changed=true | |
| ;; | |
| *docs/en/*) | |
| en_doc_changed=true | |
| ;; | |
| *docs/assets/* | *docs/doxgen/* | *docs/examples/*) | |
| zh_doc_changed=true | |
| en_doc_changed=true | |
| ;; | |
| esac | |
| done | |
| echo "zh_doc_changed=$zh_doc_changed" | |
| echo "en_doc_changed=$en_doc_changed" | |
| echo "zh_doc_changed=$zh_doc_changed" >> $GITHUB_OUTPUT | |
| echo "en_doc_changed=$en_doc_changed" >> $GITHUB_OUTPUT | |
| - name: Build the chinese document | |
| if: ${{ steps.check-doc-lang.outputs.zh_doc_changed == 'true'}} | |
| run: | | |
| cd ${{ env.DOC_WKC }}/${{ env.ZH_DOC_REPO }} | |
| rm -rf docs/* && git restore docs/ | |
| git checkout -f master && git pull origin master | |
| yarn install | |
| yarn ass local | |
| yarn build | |
| - name: Build the english document | |
| if: ${{ steps.check-doc-lang.outputs.en_doc_changed == 'true'}} | |
| run: | | |
| cd ${{ env.DOC_WKC }}/${{ env.EN_DOC_REPO }} | |
| rm -rf docs/* && git restore docs/ | |
| git checkout -f main && git pull origin main | |
| yarn install | |
| yarn ass local | |
| yarn build |