Repository navigation
123 lines (107 loc) · 4.34 KB
/
Copy pathdocs_release_auto_sync_pr.yml
File metadata and controls
123 lines (107 loc) · 4.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: docs-release-auto-sync-pr
on:
release:
types: [published]
jobs:
auto-sync-docs-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
concurrency:
group: docs-release-auto-sync-${{ github.ref }}
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install CAMEL
run: python -m pip install -e .
- name: Verify doc_code_map
run: python docs/mintlify/scripts/docs_sync/doc_code_map.py verify
- name: Determine refs
id: refs
run: |
current_tag="${{ github.event.release.tag_name }}"
prev_tag=$(git describe --tags --abbrev=0 "${current_tag}^" 2>/dev/null || true)
if [ -z "$prev_tag" ]; then
echo "No previous tag found; skip auto docs sync."
echo "base=" >> "$GITHUB_OUTPUT"
echo "head=" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "base=$prev_tag" >> "$GITHUB_OUTPUT"
echo "head=$current_tag" >> "$GITHUB_OUTPUT"
- name: Compute impacted docs
if: steps.refs.outputs.base != ''
id: impacted
run: |
git diff --name-only "${{ steps.refs.outputs.base }}..${{ steps.refs.outputs.head }}" -- '*.py' > changed_python_files.txt || true
echo "Changed Python files:"
cat changed_python_files.txt || true
if [ ! -s changed_python_files.txt ]; then
echo "No changed Python files. Skip auto docs PR."
echo "has_impacted_docs=false" >> "$GITHUB_OUTPUT"
exit 0
fi
python docs/mintlify/scripts/docs_sync/doc_code_map.py impacted \
--changed-files-file changed_python_files.txt > impacted_docs.txt
cat impacted_docs.txt
if [ -s impacted_docs.txt ]; then
echo "has_impacted_docs=true" >> "$GITHUB_OUTPUT"
else
echo "has_impacted_docs=false" >> "$GITHUB_OUTPUT"
fi
- name: Skip when no impacted docs
if: steps.refs.outputs.base != '' && steps.impacted.outputs.has_impacted_docs != 'true'
run: |
echo "No impacted docs. Skip auto docs PR."
- name: Auto update impacted docs with ChatAgent
if: steps.impacted.outputs.has_impacted_docs == 'true'
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
if [ -z "${OPENAI_API_KEY}" ]; then
echo "OPENAI_API_KEY is required for auto doc sync."
exit 1
fi
python .camel/skills/docs-incremental-update/scripts/auto_sync_docs_with_chatagent.py \
--docs-file impacted_docs.txt \
--changed-files-file changed_python_files.txt \
--model-platform openai \
--model-type gpt-5.4
- name: Detect generated doc changes
if: steps.impacted.outputs.has_impacted_docs == 'true'
id: changes
run: |
if git diff --quiet -- docs/mintlify/key_modules docs/mintlify/mcp; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
echo "Docs were already in sync after auto-update."
exit 0
fi
echo "has_changes=true" >> "$GITHUB_OUTPUT"
git diff --stat -- docs/mintlify/key_modules docs/mintlify/mcp
- name: Create docs sync PR
if: steps.changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v6
with:
base: ${{ github.event.repository.default_branch }}
branch: bot/docs-sync-${{ github.run_id }}
delete-branch: true
commit-message: "docs: auto sync mapped docs for ${{ steps.refs.outputs.head }}"
title: "docs: auto sync mapped docs for ${{ steps.refs.outputs.head }}"
body: |
Auto-generated docs sync PR for a release diff.
Base ref: `${{ steps.refs.outputs.base }}`
Head ref: `${{ steps.refs.outputs.head }}`
Updated by CAMEL ChatAgent for docs selected via `doc_code_map`,
with `changed_python_files.txt` provided as context.
labels: documentation, automated-pr
add-paths: |
docs/mintlify/key_modules
docs/mintlify/mcp