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/typos@v1.31.1 with: files: 'docs/zh/' config: docs/typos.toml - name: Use custom en config file uses: crate-ci/typos@v1.31.1 with: files: 'docs/en/' config: docs/typos.toml - name: Use custom en config file uses: crate-ci/typos@v1.31.1 with: files: './*.md' config: docs/typos.toml check-with-autocorrect: runs-on: ubuntu-latest permissions: pull-requests: write steps: - uses: actions/checkout@v4 - name: AutoCorrect uses: huacnlee/autocorrect-action@v2 with: args: --lint docs/zh/* docs/en/* continue-on-error: true - name: Report ReviewDog if: failure() && steps.autocorrect.conclusion == '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 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 }} 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 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 ass local yarn build