Skip to content

Commit e17e86f

Browse files
committed
feat: add update-en-docs action
1 parent bbca86f commit e17e86f

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

.github/workflows/update-en-docs.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Update Next.js English Documentation
2+
3+
on:
4+
workflow_dispatch: # Manual trigger
5+
schedule:
6+
# 8 AM Los Angeles (Pacific) time - corresponds to UTC-7 (PDT) or UTC-8 (PST)
7+
# This cron format is in UTC, so 15:00 UTC during PDT, 16:00 UTC during PST
8+
- cron: "0 15 * * *"
9+
10+
# Add permissions needed for creating PRs
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
update-docs:
17+
name: Update Next.js Docs
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Check if PR branch exists
26+
id: check_branch
27+
run: |
28+
if git ls-remote --heads origin "docs-update-nextjs-documentation" | grep -q "docs-update-nextjs-documentation"; then
29+
echo "Branch already exists, skipping update"
30+
echo "branch_exists=true" >> $GITHUB_OUTPUT
31+
else
32+
echo "Branch does not exist, proceeding with update"
33+
echo "branch_exists=false" >> $GITHUB_OUTPUT
34+
fi
35+
36+
- name: Clone Next.js repository (canary)
37+
if: steps.check_branch.outputs.branch_exists == 'false'
38+
run: |
39+
git clone --depth 1 --branch canary --single-branch https://github.com/vercel/next.js.git nextjs-canary
40+
mkdir -p apps/docs/content/en/docs
41+
rsync -av --delete nextjs-canary/docs/ apps/docs/content/en/docs/ --exclude="13" --exclude="14"
42+
rm -rf nextjs-canary
43+
44+
- name: Clone Next.js repository (v14.2.28)
45+
if: steps.check_branch.outputs.branch_exists == 'false'
46+
run: |
47+
git clone --depth 1 --branch v14.2.28 --single-branch https://github.com/vercel/next.js.git nextjs-v14
48+
mkdir -p apps/docs/content/en/docs/14
49+
rsync -av --delete nextjs-v14/docs/ apps/docs/content/en/docs/14/
50+
rm -rf nextjs-v14
51+
52+
- name: Clone Next.js repository (v13.5.11)
53+
if: steps.check_branch.outputs.branch_exists == 'false'
54+
run: |
55+
git clone --depth 1 --branch v13.5.11 --single-branch https://github.com/vercel/next.js.git nextjs-v13
56+
mkdir -p apps/docs/content/en/docs/13
57+
rsync -av --delete nextjs-v13/docs/ apps/docs/content/en/docs/13/
58+
rm -rf nextjs-v13
59+
60+
- name: Check for modifications
61+
if: steps.check_branch.outputs.branch_exists == 'false'
62+
id: check_changes
63+
run: |
64+
if [[ $(git status --porcelain | grep -E "apps/docs/content/en/docs" | wc -l) -gt 0 ]]; then
65+
echo "has_changes=true" >> $GITHUB_OUTPUT
66+
echo "Changes detected. Will proceed with PR."
67+
else
68+
echo "has_changes=false" >> $GITHUB_OUTPUT
69+
echo "No changes detected in docs. Skipping PR."
70+
fi
71+
72+
- name: Create Pull Request
73+
if: steps.check_branch.outputs.branch_exists == 'false' && steps.check_changes.outputs.has_changes == 'true'
74+
uses: peter-evans/create-pull-request@v5
75+
with:
76+
token: ${{ secrets.GITHUB_TOKEN }}
77+
commit-message: "docs: update nextjs documentation"
78+
title: "docs: update nextjs documentation"
79+
body: |
80+
This PR updates the Next.js English documentation from the official Next.js repository.
81+
- Updates from `canary` branch to `apps/docs/content/en/docs`
82+
- Updates from `v14.2.28` branch to `apps/docs/content/en/docs/14`
83+
- Updates from `v13.5.11` branch to `apps/docs/content/en/docs/13`
84+
branch: docs-update-nextjs-documentation
85+
delete-branch: true
86+
base: main
87+
add-paths: |
88+
apps/docs/content/en/docs

0 commit comments

Comments
 (0)