1
+ name : Update Claude Code Documentation
2
+
3
+ on :
4
+ schedule :
5
+ # Run every 3 hours (at 00:00, 03:00, 06:00, 09:00, 12:00, 15:00, 18:00, 21:00 UTC)
6
+ - cron : ' 0 */3 * * *'
7
+ workflow_dispatch : # Allow manual trigger
8
+
9
+ permissions :
10
+ contents : write
11
+ issues : write
12
+
13
+ jobs :
14
+ update-docs :
15
+ runs-on : ubuntu-latest
16
+
17
+ steps :
18
+ - name : Checkout repository
19
+ uses : actions/checkout@v4
20
+ with :
21
+ token : ${{ secrets.GITHUB_TOKEN }}
22
+ ref : main
23
+
24
+ - name : Set up Python
25
+ uses : actions/setup-python@v5
26
+ with :
27
+ python-version : ' 3.11'
28
+
29
+ - name : Install dependencies
30
+ run : |
31
+ python -m pip install --upgrade pip
32
+ pip install -r scripts/requirements.txt
33
+
34
+ - name : Fetch latest documentation
35
+ id : fetch-docs
36
+ env :
37
+ GITHUB_REPOSITORY : ${{ github.repository }}
38
+ GITHUB_REF_NAME : ${{ github.ref_name }}
39
+ run : |
40
+ python scripts/fetch_claude_docs.py || echo "fetch_failed=true" >> $GITHUB_OUTPUT
41
+ continue-on-error : true
42
+
43
+ - name : Check for changes
44
+ id : verify-changed-files
45
+ run : |
46
+ git diff --exit-code || echo "changed=true" >> $GITHUB_OUTPUT
47
+
48
+ - name : Generate commit message
49
+ if : steps.verify-changed-files.outputs.changed == 'true'
50
+ id : commit-msg
51
+ run : |
52
+ # Stage changes to see what will be committed
53
+ git add -A docs/
54
+
55
+ # Get list of changed files
56
+ CHANGED_FILES=$(git diff --name-status --cached | grep "^M" | cut -f2 | grep -E "\.md$" | sed 's/docs\///' | paste -sd ", " -)
57
+ ADDED_FILES=$(git diff --name-status --cached | grep "^A" | cut -f2 | grep -E "\.md$" | sed 's/docs\///' | paste -sd ", " -)
58
+ DELETED_FILES=$(git diff --name-status --cached | grep "^D" | cut -f2 | grep -E "\.md$" | sed 's/docs\///' | paste -sd ", " -)
59
+
60
+ # Build commit message
61
+ COMMIT_MSG="Update Claude Code docs - $(date +'%Y-%m-%d')"
62
+
63
+ if [ -n "$CHANGED_FILES" ]; then
64
+ COMMIT_MSG="$COMMIT_MSG | Updated: $CHANGED_FILES"
65
+ fi
66
+
67
+ if [ -n "$ADDED_FILES" ]; then
68
+ COMMIT_MSG="$COMMIT_MSG | Added: $ADDED_FILES"
69
+ fi
70
+
71
+ if [ -n "$DELETED_FILES" ]; then
72
+ COMMIT_MSG="$COMMIT_MSG | Removed: $DELETED_FILES"
73
+ fi
74
+
75
+ echo "message=$COMMIT_MSG" >> $GITHUB_OUTPUT
76
+
77
+ - name : Commit and push if changed
78
+ if : steps.verify-changed-files.outputs.changed == 'true'
79
+ run : |
80
+ git config --local user.email "github-actions[bot]@users.noreply.github.com"
81
+ git config --local user.name "github-actions[bot]"
82
+ # Files already staged in previous step
83
+ git commit -m "${{ steps.commit-msg.outputs.message }}"
84
+ git push
85
+
86
+ - name : Create issue on failure
87
+ if : steps.fetch-docs.outputs.fetch_failed == 'true'
88
+ uses : actions/github-script@v7
89
+ with :
90
+ script : |
91
+ const date = new Date().toISOString().split('T')[0];
92
+ await github.rest.issues.create({
93
+ owner: context.repo.owner,
94
+ repo: context.repo.repo,
95
+ title: `Documentation update failed - ${date}`,
96
+ body: `The automated documentation update failed on ${date}.\n\nPlease check the [workflow run](${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}) for details.`,
97
+ labels: ['bug', 'automation']
98
+ })
0 commit comments