Sync Next.js Official Documentation #18
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: Sync Next.js Official Documentation | |
| on: | |
| workflow_dispatch: # Manual trigger | |
| schedule: | |
| # 8 AM Los Angeles (Pacific) time - corresponds to UTC-7 (PDT) or UTC-8 (PST) | |
| # This cron format is in UTC, so 15:00 UTC during PDT, 16:00 UTC during PST | |
| - cron: "0 15 * * *" | |
| # Add permissions needed for creating PRs | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| check-branch: | |
| name: Check if PR branch exists | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_sync: ${{ steps.check_branch.outputs.should_sync }} | |
| steps: | |
| - name: Check if PR branch exists | |
| id: check_branch | |
| run: | | |
| if git ls-remote --heads https://github.com/${{ github.repository }}.git | grep -q "docs/sync-nextjs-documentation"; then | |
| echo "Branch already exists, skipping update" | |
| echo "should_sync=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Branch does not exist, proceeding with update" | |
| echo "should_sync=true" >> $GITHUB_OUTPUT | |
| fi | |
| sync-docs: | |
| name: Sync Next.js Docs | |
| runs-on: ubuntu-latest | |
| needs: check-branch | |
| if: needs.check-branch.outputs.should_sync == 'true' | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Clone Next.js repository (canary) | |
| run: | | |
| git clone --depth 1 --branch canary --single-branch https://github.com/vercel/next.js.git nextjs-canary | |
| mkdir -p apps/docs/content/en/docs | |
| rsync -av --delete nextjs-canary/docs/ apps/docs/content/en/docs/ --exclude="13" --exclude="14" | |
| rm -rf nextjs-canary | |
| - name: Clone Next.js repository (v14.2.28) | |
| run: | | |
| git clone --depth 1 --branch v14.2.28 --single-branch https://github.com/vercel/next.js.git nextjs-v14 | |
| mkdir -p apps/docs/content/en/docs/14 | |
| rsync -av --delete nextjs-v14/docs/ apps/docs/content/en/docs/14/ | |
| rm -rf nextjs-v14 | |
| - name: Clone Next.js repository (v13.5.11) | |
| run: | | |
| git clone --depth 1 --branch v13.5.11 --single-branch https://github.com/vercel/next.js.git nextjs-v13 | |
| mkdir -p apps/docs/content/en/docs/13 | |
| rsync -av --delete nextjs-v13/docs/ apps/docs/content/en/docs/13/ | |
| rm -rf nextjs-v13 | |
| - name: Setup Tools | |
| uses: ./.github/actions/setup | |
| - name: Sync blog & learn | |
| run: | | |
| node packages/crawler/dist/index.js | |
| - name: Stage changes to detect renames | |
| run: | | |
| # Stage all changes so Git can detect renames | |
| git add . | |
| # Show what Git sees after staging | |
| echo "Git status after staging:" | |
| git status --porcelain | |
| - name: Process file renames and deletions | |
| run: | | |
| node .github/scripts/process-file-changes.js | |
| - name: Check for modifications | |
| id: check_changes | |
| run: | | |
| if [[ $(git status --porcelain | grep -E "apps/docs/content/" | wc -l) -gt 0 ]]; then | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| echo "Changes detected. Will proceed with PR." | |
| else | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| echo "No changes detected in docs. Skipping PR." | |
| fi | |
| - name: Create Pull Request | |
| if: steps.check_changes.outputs.has_changes == 'true' | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| token: ${{ secrets.PAT_TOKEN }} # Use PAT instead of GITHUB_TOKEN | |
| commit-message: "docs: update nextjs documentation" | |
| title: "docs: update nextjs documentation" | |
| body: | | |
| This PR updates the Next.js English documentation from the official Next.js repository. | |
| - Updates from `canary` branch to `apps/docs/content/en/docs` | |
| - Updates from `v14.2.28` branch to `apps/docs/content/en/docs/14` | |
| - Updates from `v13.5.11` branch to `apps/docs/content/en/docs/13` | |
| - Updates from blog to `apps/docs/content/en/blog` | |
| - Updates from learn to `apps/docs/content/en/learn` | |
| branch: docs/sync-nextjs-documentation | |
| delete-branch: true | |
| base: dev | |
| add-paths: | | |
| apps/docs/content/ |