Update Documentation #3661
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: "Update Documentation" | |
| on: | |
| # Manual trigger from GitHub UI | |
| workflow_dispatch: | |
| inputs: | |
| reason: | |
| description: "Reason for updating docs" | |
| required: false | |
| default: "Manual update" | |
| type: "string" | |
| force_update: | |
| description: "Force update even if no changes detected" | |
| required: false | |
| default: false | |
| type: "boolean" | |
| # Trigger from other repositories | |
| repository_dispatch: | |
| types: ["update-docs"] | |
| # Scheduled update (every hour at minute 0) | |
| schedule: | |
| - cron: "0 * * * *" | |
| # Trigger when the download script is updated | |
| push: | |
| paths: | |
| - "scripts/download-visulima-docs.js" | |
| - ".github/workflows/update-docs.yml" | |
| jobs: | |
| update-documentation: | |
| name: "Download and Update Documentation" | |
| runs-on: "ubuntu-latest" | |
| permissions: | |
| contents: "write" | |
| steps: | |
| - name: "Harden Runner" | |
| uses: "step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2" # v2.13.3 | |
| with: | |
| egress-policy: "audit" | |
| - name: "Git checkout ${{ env.HEAD_REPOSITORY }}:${{ env.HEAD_REF }}" | |
| uses: "actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd" # v5.0.1 | |
| env: | |
| GIT_COMMITTER_NAME: "GitHub Actions Shell" | |
| GIT_AUTHOR_NAME: "GitHub Actions Shell" | |
| EMAIL: "github-actions[bot]@users.noreply.github.com" | |
| with: | |
| # Number of commits to fetch. 0 indicates all history for all branches and tags. | |
| # Pulls all commits (needed for NX) | |
| fetch-depth: 0 | |
| - name: "Setup resources and environment" | |
| id: "setup" | |
| uses: "anolilab/workflows/step/setup@main" | |
| with: | |
| node-version: "22" | |
| install-bun: false | |
| skip-playwright: true | |
| - name: "Clean previous downloads" | |
| run: | | |
| echo "Cleaning previous documentation downloads..." | |
| rm -rf downloaded-docs | |
| # Note: The script now moves files to src/content/docs/packages and cleans up automatically | |
| - name: "Download latest documentation" | |
| env: | |
| GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
| run: | | |
| echo "Starting documentation download..." | |
| echo "Trigger: ${{ github.event_name }}" | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "Reason: ${{ github.event.inputs.reason }}" | |
| echo "Force update: ${{ github.event.inputs.force_update }}" | |
| elif [ "${{ github.event_name }}" = "repository_dispatch" ]; then | |
| echo "Repository: ${{ github.event.client_payload.repository }}" | |
| echo "Ref: ${{ github.event.client_payload.ref }}" | |
| fi | |
| # Run the documentation download script | |
| pnpm run download-docs | |
| - name: "Commit and push changes" | |
| uses: "stefanzweifel/git-auto-commit-action@28e16e81777b558cc906c8750092100bbb34c5e3" # v7.0.0 | |
| with: | |
| commit_message: | | |
| docs: update Visulima documentation | |
| - Downloaded latest documentation | |
| - Triggered by: ${{ github.event_name }} | |
| ${{ github.event_name == 'workflow_dispatch' && format('- Reason: {0}', github.event.inputs.reason) || '' }} | |
| ${{ github.event_name == 'repository_dispatch' && format('- Source repository: {0}', github.event.client_payload.repository) || '' }} | |
| commit_user_name: "visulima-docs-bot" | |
| commit_user_email: "docs-bot@visulima.com" | |
| commit_author: "Visulima Docs Bot <docs-bot@visulima.com>" | |
| file_pattern: "src/content/docs/packages/**" | |
| push_options: "--force-with-lease" | |
| skip_dirty_check: false | |
| skip_fetch: false | |
| skip_checkout: false | |
| disable_globbing: false | |
| - name: "Get current date" | |
| id: "date" | |
| run: "echo \"date=$(date +'%Y-%m-%d %H:%M:%S UTC')\" >> $GITHUB_OUTPUT" | |
| - name: "Add job summary" | |
| if: "always()" | |
| run: | | |
| echo "## Documentation Update Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Workflow**: Update Documentation" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Trigger**: ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Timestamp**: ${{ steps.date.outputs.date }}" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "- **Reason**: ${{ github.event.inputs.reason }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Force update**: ${{ github.event.inputs.force_update }}" >> $GITHUB_STEP_SUMMARY | |
| elif [ "${{ github.event_name }}" = "repository_dispatch" ]; then | |
| echo "- **Source repository**: ${{ github.event.client_payload.repository }}" >> $GITHUB_STEP_SUMMARY | |
| echo "- **Source ref**: ${{ github.event.client_payload.ref }}" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| - name: "Notify on failure" | |
| if: "failure()" | |
| run: | | |
| echo "Documentation update failed!" >> $GITHUB_STEP_SUMMARY | |
| echo "Check the workflow logs for more details." >> $GITHUB_STEP_SUMMARY |