📖 Check docs 6bbc8dda387da40d181bac89ab633605be1fbdfb #445
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: 📖 Check docs | |
| run-name: 📖 Check docs ${{ github.sha }} | |
| on: | |
| workflow_call: | |
| pull_request: | |
| paths: | |
| - 'manual/**' | |
| branches: | |
| - master | |
| - manticore-* | |
| jobs: | |
| translate_docs: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Check origin repository | |
| id: repo-check | |
| run: | | |
| if [ "${{ github.event_name }}" == "pull_request" ]; then | |
| repo="${{ github.event.pull_request.head.repo.full_name }}" | |
| else | |
| repo="${{ github.repository }}" | |
| fi | |
| echo "repo=$repo" >> $GITHUB_OUTPUT | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| repository: ${{ steps.repo-check.outputs.repo }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| submodules: true | |
| ref: ${{ github.head_ref }} | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| tools: composer | |
| extensions: curl | |
| - name: Run auto-translate | |
| env: | |
| OPENROUTER_TRANSLATOR_API_KEY: ${{ secrets.OPENROUTER_TRANSLATOR_API_KEY }} | |
| run: | | |
| set -e | |
| # Install PHP dependencies for translator | |
| cd translator | |
| composer install --no-dev --no-interaction --prefer-dist | |
| cd .. | |
| # Configure git for commits | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| # Run auto-translate | |
| ./translator/bin/auto-translate | |
| # Check if there are any changes to commit (including untracked files) | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "Auto-translate made changes, committing them..." | |
| git add -A | |
| git commit -m "docs: Auto-translate documentation changes by ${{ github.actor }}" | |
| git push | |
| echo "Changes committed and pushed successfully" | |
| else | |
| echo "No changes made by auto-translate" | |
| fi | |
| docs_check: | |
| needs: translate_docs | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: write | |
| pull-requests: read | |
| defaults: | |
| run: | |
| shell: bash | |
| container: | |
| image: manticoresearch/docs_autodeploy_multi:latest | |
| env: | |
| CACHEB: "../cache" | |
| DOCKER_HOST: tcp://docker:2375/ | |
| DOCKER_DRIVER: overlay2 | |
| COMMIT_DIR: manual | |
| DOCS_ERRORS_DIR: build/docs/ | |
| GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | |
| steps: | |
| - name: Check origin repository | |
| id: repo-check | |
| run: | | |
| if [ "${{ github.event_name }}" == "pull_request" ]; then | |
| repo="${{ github.event.pull_request.head.repo.full_name }}" | |
| else | |
| repo="${{ github.repository }}" | |
| fi | |
| echo "repo=$repo" >> $GITHUB_OUTPUT | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| repository: ${{ steps.repo-check.outputs.repo }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| submodules: true | |
| ref: ${{ github.head_ref }} | |
| - name: Fetch master and get changed files | |
| id: changed-files | |
| run: | | |
| git config --global --add safe.directory /__w/manticoresearch/manticoresearch | |
| # Update local master only if we're not currently on it | |
| if [ "${{ github.ref_name }}" != "master" -a "${{ github.event_name }}" != "pull_request" ]; then | |
| git fetch origin master:master | |
| fi | |
| git diff-tree --no-commit-id --name-only -r HEAD^1 HEAD | xargs | |
| echo "changed_files=$(git diff-tree --no-commit-id --name-only -r HEAD^1 HEAD | xargs)" >> $GITHUB_OUTPUT | |
| - name: Get changed doc filepathes | |
| id: doc-filepathes | |
| run: | | |
| filepathes="" | |
| for file in ${{ steps.changed-files.outputs.changed_files }}; do | |
| case "$file" in | |
| "$COMMIT_DIR/"*) | |
| filepathes="$file $filepathes" | |
| ;; | |
| esac | |
| done | |
| echo "$filepathes" | |
| echo "filepathes=$filepathes" >> $GITHUB_OUTPUT | |
| - name: Check docs | |
| id: check | |
| run: | | |
| docs_errors=$(php "/Deploy/check_docs_validity.php" "${{ steps.doc-filepathes.outputs.filepathes }}" "$COMMIT_DIR/" "$DOCS_ERRORS_DIR" | xargs) | |
| echo $docs_errors | |
| echo "errors=$docs_errors" >> $GITHUB_OUTPUT | |
| - name: Check docs translations | |
| run: | | |
| set -e | |
| ./misc/compare_manuals.sh | |
| - name: Upload artifact | |
| uses: manticoresoftware/upload_artifact_with_retries@v4 | |
| with: | |
| name: Docs error artifact | |
| path: $DOCS_ERRORS_DIR | |
| - name: Display result | |
| run: | | |
| if [ "${{ steps.check.outputs.errors }}" != "" ]; then | |
| exit 1 | |
| fi | |
| echo "Doc check passed successfully " | |