Repo sync #8978
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: Test changed content | |
| # Renders changed pages and checks that deleted or renamed URLs still resolve before main-bound PRs merge. | |
| on: | |
| pull_request: | |
| branches: | |
| # Megabranch PRs may skip deleted-page checks, but main-bound PRs must keep old URLs resolving. | |
| - main | |
| paths: | |
| - 'content/**' | |
| - .github/workflows/test-changed-content.yml | |
| permissions: | |
| contents: read | |
| jobs: | |
| test-changed-content: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.repository == 'github/docs-internal' || github.repository == 'github/docs' }} | |
| steps: | |
| # Repeat each if on its step so skipped work still leaves the required check present. | |
| - name: Check out repo | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| # Fetch 2 commits so tj-actions/changed-files can diff without extra API calls | |
| fetch-depth: 2 | |
| - uses: ./.github/actions/node-npm-setup | |
| - uses: ./.github/actions/get-docs-early-access | |
| if: ${{ github.repository == 'github/docs-internal' }} | |
| with: | |
| token: ${{ secrets.DOCS_BOT_PAT_BASE }} | |
| - uses: ./.github/actions/cache-nextjs | |
| - name: Run build script | |
| run: npm run build | |
| - name: Get changed files | |
| id: changed_files | |
| uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5 | |
| with: | |
| files: 'content/**' | |
| # all_old_new_renamed_files exposes old,new pairs for renames. | |
| # Without it, git status R files skip the deleted-file redirect check and old URLs 404. | |
| include_all_old_new_renamed_files: true | |
| - name: Run tests | |
| env: | |
| CHANGED_FILES: ${{ steps.changed_files.outputs.all_modified_files }} | |
| DELETED_FILES: ${{ steps.changed_files.outputs.deleted_files }} | |
| # Space-separated oldPath,newPath pairs; the test checks each old path like a deleted file. | |
| RENAMED_FILES: ${{ steps.changed_files.outputs.all_old_new_renamed_files }} | |
| run: npm test -- src/content-render/tests/render-changed-and-deleted-files.ts |