Vortex - Test docs #3635
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
| # This action is used for Vortex maintenance. It will not be used in the scaffolded project. | |
| name: Vortex - Test docs | |
| on: | |
| workflow_run: | |
| workflows: ['Vortex - Test installer'] | |
| types: | |
| - completed | |
| jobs: | |
| vortex-test-docs: | |
| runs-on: ubuntu-latest | |
| # Only run if installer workflow succeeded | |
| if: github.event.workflow_run.conclusion == 'success' | |
| permissions: | |
| contents: read # Checkout the repository at the triggering commit. | |
| actions: read # Download the installer artifact from the test-installer workflow run. | |
| statuses: write # Post pending/final commit statuses via 'gh api repos/.../statuses/...'. | |
| pull-requests: write # Post the Netlify preview link comment on the originating PR. | |
| steps: | |
| # Post pending status to the PR commit. | |
| # Workflows triggered by workflow_run don't automatically report status | |
| # on the triggering PR, so we need to do it manually. | |
| - name: Set pending commit status | |
| run: | | |
| gh api "repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_EVENT_WORKFLOW_RUN_HEAD_SHA}" \ | |
| -f state=pending \ | |
| -f context="Vortex - Test docs" \ | |
| -f description="Running documentation tests..." \ | |
| -f target_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GITHUB_EVENT_WORKFLOW_RUN_HEAD_SHA: ${{ github.event.workflow_run.head_sha }} | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| persist-credentials: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 | |
| with: | |
| node-version: 22.17.1 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2 | |
| with: | |
| php-version: 8.3 | |
| - name: Download installer artifact | |
| uses: dawidd6/action-download-artifact@b6e2e70617bc3265edd6dab6c906732b2f1ae151 # v21 | |
| with: | |
| workflow: vortex-test-installer.yml | |
| name: vortex-installer | |
| path: .vortex/docs/static | |
| if_no_artifact_found: fail | |
| allow_forks: true | |
| - name: Copy installer to docs | |
| run: | | |
| mv .vortex/docs/static/installer.phar .vortex/docs/static/install | |
| php .vortex/docs/static/install --version | |
| - name: Check docs up-to-date | |
| run: | | |
| yarn run update-variables | |
| git diff --quiet HEAD || { echo "Docs not up-to-date. Run 'cd .vortex && ahoy update-docs' and commit changes."; git diff; exit 1; } | |
| working-directory: '${{ github.workspace }}/.vortex/docs' | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| working-directory: '${{ github.workspace }}/.vortex/docs' | |
| - name: Lint code | |
| run: yarn run lint | |
| working-directory: '${{ github.workspace }}/.vortex/docs' | |
| - name: Run tests | |
| run: yarn run test:coverage | |
| working-directory: '${{ github.workspace }}/.vortex/docs' | |
| - name: Check spelling | |
| run: yarn run spellcheck | |
| working-directory: '${{ github.workspace }}/.vortex/docs' | |
| - name: Build documentation site | |
| run: yarn run build | |
| working-directory: '${{ github.workspace }}/.vortex/docs' | |
| # This workflow runs via 'workflow_run', where 'github.ref' is always the | |
| # default branch, so the action's branch-based production detection cannot | |
| # distinguish a PR build from a 'main' build. Drive the decision explicitly | |
| # from the originating branch instead: 'main' publishes to production, every | |
| # other branch publishes an isolated draft preview. The action's own comment | |
| # and deployment features are disabled - they require a PR context this | |
| # 'workflow_run' event does not carry; the next step posts the link instead. | |
| - name: Deploy to Netlify | |
| id: netlify | |
| uses: nwtgck/actions-netlify@d22a32a27c918fe470bbc562e984f80ec48c2668 # v4.0 | |
| with: | |
| publish-dir: '.vortex/docs/build' | |
| production-deploy: ${{ github.event.workflow_run.head_branch == 'main' }} | |
| deploy-message: "Deploy from GitHub Actions" | |
| enable-pull-request-comment: false | |
| enable-commit-comment: false | |
| enable-commit-status: false | |
| enable-github-deployment: false | |
| env: | |
| NETLIFY_SITE_ID: ${{ secrets.DOCS_NETLIFY_SITE_ID }} | |
| NETLIFY_AUTH_TOKEN: ${{ secrets.DOCS_NETLIFY_AUTH_TOKEN }} | |
| timeout-minutes: 1 | |
| # Post the Netlify preview URL as a sticky comment on the originating PR. | |
| # Runs only for PR builds (not 'main') that produced a preview URL; skipped | |
| # on forks, where 'pull_requests' is empty. | |
| - name: Post documentation preview link | |
| if: github.event.workflow_run.head_branch != 'main' && github.event.workflow_run.pull_requests[0].number && steps.netlify.outputs.deploy-url | |
| uses: marocchino/sticky-pull-request-comment@70d2764d1a7d5d9560b100cbea0077fc8f633987 # v3 | |
| with: | |
| number: ${{ github.event.workflow_run.pull_requests[0].number }} | |
| header: docs-preview | |
| message: | | |
| π Documentation preview for this pull request has been deployed to Netlify: | |
| ${{ steps.netlify.outputs.deploy-url }} | |
| This preview is rebuilt on every commit and is not the production documentation site. | |
| - name: Upload coverage reports as an artifact | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 | |
| with: | |
| name: ${{github.job}}-docs-coverage-report | |
| path: .vortex/docs/.logs | |
| include-hidden-files: true | |
| if-no-files-found: error | |
| - name: Upload coverage report to Codecov | |
| uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7 | |
| continue-on-error: true | |
| with: | |
| files: .vortex/docs/.logs/cobertura.xml | |
| fail_ci_if_error: true | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| # Post final status to the PR commit. | |
| - name: Set final commit status | |
| if: always() | |
| run: | | |
| state=${{ job.status == 'success' && 'success' || 'failure' }} | |
| description=${{ job.status == 'success' && '"Documentation tests passed"' || '"Documentation tests failed"' }} | |
| gh api "repos/${GITHUB_REPOSITORY}/statuses/${GITHUB_EVENT_WORKFLOW_RUN_HEAD_SHA}" \ | |
| -f state="${state}" \ | |
| -f context="Vortex - Test docs" \ | |
| -f description="${description}" \ | |
| -f target_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GITHUB_EVENT_WORKFLOW_RUN_HEAD_SHA: ${{ github.event.workflow_run.head_sha }} |