Skip to content

Commit e6571b0

Browse files
authored
Enhance export-docs workflow for PR branch tracking (#1656)
Updated checkout step to track the PR branch and modified fetch depth. Added a step to sync with existing PR branch if it exists.
1 parent 9e023cb commit e6571b0

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

.github/workflows/export-docs.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,31 @@ jobs:
3030
token: ${{ secrets.EXPORT_PAT }}
3131

3232
# ----------------------------------------------------------------
33-
# 2. Check out markdown-service into a sibling directory
33+
# 2. Check out markdown-service and try to track the PR branch
3434
# ----------------------------------------------------------------
3535
- name: Check out markdown-service
3636
uses: actions/checkout@v4
3737
with:
3838
repository: AgoraIO/markdown-service
3939
token: ${{ secrets.EXPORT_PAT }}
4040
path: markdown-service
41-
fetch-depth: 1
41+
fetch-depth: 0 # Changed to 0 so we can find existing remote branches
4242

43+
# ----------------------------------------------------------------
44+
# 2.5 Prepare branch to accumulate changes
45+
# ----------------------------------------------------------------
46+
- name: Sync with existing PR branch if it exists
47+
working-directory: markdown-service
48+
run: |
49+
# Check if the automated branch already exists on the remote
50+
if git show-ref --verify --quiet refs/remotes/origin/auto-export/latest; then
51+
echo "Found existing PR branch. Fetching and checking it out to accumulate changes..."
52+
git checkout auto-export/latest
53+
git pull origin auto-export/latest
54+
else
55+
echo "No existing PR branch found. Starting fresh from main."
56+
fi
57+
4358
# ----------------------------------------------------------------
4459
# 3. Fetch products.js from the private AgoraIO/Docs repo
4560
# ----------------------------------------------------------------
@@ -183,4 +198,4 @@ jobs:
183198
# ----------------------------------------------------------------
184199
- name: No changes to export
185200
if: steps.changes.outputs.changed == 'false'
186-
run: echo "✅ No markdown files changed — no PR needed."
201+
run: echo "✅ No markdown files changed — no PR needed."

0 commit comments

Comments
 (0)