The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
docs - automate doc generation (#62237)
Jeff Bruemmerbd181add0b82
diff --git a/.github/workflows/docs-master-generate.yml b/.github/workflows/docs-master-generate.ymlnew file mode 100644index 00000000000..f3e5789953d--- /dev/null+++ b/.github/workflows/docs-master-generate.yml@@ -0,0 +1,139 @@+name: Auto-update documentation++on:+ schedule:+ - cron: "0 1 * * 2" # Every Tuesday at 1 AM UTC+ workflow_dispatch:++permissions:+ contents: write+ pull-requests: write++jobs:+ update-docs:+ name: Update documentation+ runs-on: ubuntu-22.04+ timeout-minutes: 30+ steps:+ - name: Checkout code+ uses: actions/checkout@v4+ with:+ fetch-depth: 0+ token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}++ - name: Prepare backend environment+ uses: ./.github/actions/prepare-backend+ with:+ m2-cache-key: "auto-update-docs"++ - name: Generate environment variables documentation+ id: generate_env_docs+ run: |+ set -e # Exit on any error+ clojure -M:ee:doc environment-variables-documentation+ continue-on-error: false++ - name: Generate config template documentation+ id: generate_config_docs+ run: |+ set -e # Exit on any error+ clojure -M:ee:doc config-template+ continue-on-error: false++ - name: Generate API documentation+ id: generate_api_docs+ run: |+ set -e # Exit on any error+ clojure -M:ee:doc api-documentation+ continue-on-error: false++ - name: Check for changes+ id: check_changes+ run: |+ if git diff --quiet docs/; then+ echo "changes=false" >> $GITHUB_OUTPUT+ echo "No changes detected in docs directory"+ else+ echo "changes=true" >> $GITHUB_OUTPUT+ echo "Changes detected in docs directory"+ fi++ - name: Create branch and commit changes+ id: commit_and_push+ if: steps.check_changes.outputs.changes == 'true'+ run: |+ # Use timestamp with seconds to avoid conflicts+ BRANCH_NAME="docs/auto-update-$(date +%Y-%m-%d-%H%M%S)"++ git config user.name github-actions+ git config user.email [email protected]+ git checkout -b $BRANCH_NAME++ git add docs/+ git commit -m "Auto-update documentation" --no-verify+ git push -u origin $BRANCH_NAME++ echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT++ - name: Create pull request+ if: steps.check_changes.outputs.changes == 'true'+ env:+ GITHUB_TOKEN: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}+ run: |+ # Generate a summary of changes+ CHANGES_SUMMARY=$(git diff --name-only HEAD~1 docs/ 2>/dev/null | head -10 | sed 's/^/- /' || echo "- No specific files detected")++ # Count total changes for conditional message+ TOTAL_CHANGES=$(git diff --name-only HEAD~1 docs/ 2>/dev/null | wc -l || echo "0")++ # Retry PR creation up to 3 times+ for i in {1..3}; do+ if gh pr create \+ --base master \+ --head ${{ steps.commit_and_push.outputs.branch_name }} \+ --title "Auto-update documentation from Monday build" \+ --body "This PR contains automatically generated documentation updates from the Monday build process.++ ## Changes detected+ The following documentation files were updated:+ $CHANGES_SUMMARY+ $([ "$TOTAL_CHANGES" -gt 10 ] && echo "- ... and more files")++ ## Generation commands+ Documentation was generated using:+ - \`clojure -M:ee:doc environment-variables-documentation\`+ - \`clojure -M:ee:doc config-template\`+ - \`clojure -M:ee:doc api-documentation\`++ Please review the changes and merge if they look correct." \+ --label "Type:Documentation" \+ --label "no-backport"; then+ echo "PR created successfully on attempt $i"+ break+ else+ echo "PR creation failed on attempt $i"+ if [ $i -eq 3 ]; then+ echo "All retry attempts failed. PR creation unsuccessful."+ exit 1+ fi+ echo "Retrying in 10 seconds..."+ sleep 10+ fi+ done++ - name: Skip PR creation+ if: steps.check_changes.outputs.changes == 'false'+ run: |+ echo "No documentation changes detected, skipping PR creation"++ - name: Workflow summary+ if: always()+ run: |+ if [ "${{ steps.check_changes.outputs.changes }}" == "true" ]; then+ echo "## ✅ Documentation Updated Successfully" >> $GITHUB_STEP_SUMMARY+ echo "- Created branch: \`${{ steps.commit_and_push.outputs.branch_name }}\`" >> $GITHUB_STEP_SUMMARY+ echo "- Created PR for review" >> $GITHUB_STEP_SUMMARY+ else+ echo "## ℹ️ No Documentation Changes" >> $GITHUB_STEP_SUMMARY+ echo "- All documentation is up to date" >> $GITHUB_STEP_SUMMARY+ fi