Sync Next.js Official Documentation #22
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: | |
sync-docs: | |
name: Sync Next.js Docs | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if PR branch exists | |
run: | | |
if git ls-remote --heads https://github.com/${{ github.repository }}.git | grep -q "docs/sync-nextjs-documentation"; then | |
echo "::notice::Branch 'docs/sync-nextjs-documentation' already exists, skipping documentation sync" | |
exit 1 | |
else | |
echo "::notice::Branch 'docs/sync-nextjs-documentation' does not exist, proceeding with documentation sync" | |
fi | |
- 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/ |