forked from wandb/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (97 loc) · 4.44 KB
/
sync-code-examples.yml
File metadata and controls
123 lines (97 loc) · 4.44 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: Sync Code Examples from docs-code-eval
on:
workflow_dispatch: # Allows manual triggering from GitHub UI
jobs:
sync-examples:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout docs repository
uses: actions/checkout@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Run sync script
run: |
chmod +x scripts/sync_code_examples.sh
./scripts/sync_code_examples.sh
- name: Check for changes
id: check_changes
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
echo "✅ Changes detected"
else
echo "changes=false" >> $GITHUB_OUTPUT
echo "ℹ️ No changes detected"
fi
- name: Get change summary
if: steps.check_changes.outputs.changes == 'true'
id: change_summary
run: |
# Count changed files
CHANGED_FILES=$(git status --porcelain | wc -l | tr -d ' ')
CHANGED_PY=$(git status --porcelain | grep '\.py$' | wc -l | tr -d ' ')
echo "changed_files=$CHANGED_FILES" >> $GITHUB_OUTPUT
echo "changed_py=$CHANGED_PY" >> $GITHUB_OUTPUT
# Get short summary
echo "summary<<EOF" >> $GITHUB_OUTPUT
echo "Synced $CHANGED_FILES file(s) from docs-code-eval:" >> $GITHUB_OUTPUT
echo "- $CHANGED_PY Python example(s) updated" >> $GITHUB_OUTPUT
echo "- Cheat sheet regenerated" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create Pull Request
if: steps.check_changes.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: |
Sync code examples from docs-code-eval
Auto-sync of ground truth examples from docs-code-eval repository.
Updated ${{ steps.change_summary.outputs.changed_files }} file(s).
branch: sync-code-examples-${{ github.run_number }}
delete-branch: true
draft: true
title: "🔄 Sync code examples from docs-code-eval"
body: |
## 🔄 Automated Code Examples Sync
This PR syncs ground truth code examples from the [docs-code-eval](https://github.com/wandb/docs-code-eval) repository.
These examples are used to build the SDK coding cheat sheet.
### Changes
${{ steps.change_summary.outputs.summary }}
### Files Updated
- **Code Examples**: `snippets/en/_includes/code-examples/*.mdx`
- **Cheat Sheet**: `models/ref/sdk-coding-cheat-sheet/`
### Review Checklist
- [ ] Verify code examples are correct
- [ ] Check cheat sheet rendering
- [ ] Ensure all examples have proper placeholders
- [ ] Confirm difficulty levels are appropriate
### How This Works
This PR was automatically created by the [Sync Code Examples](.github/workflows/sync-code-examples.yml) workflow, which:
1. Clones the latest `docs-code-eval` repository
2. Copies ground truth examples from `ground_truth/`
3. Regenerates the SDK coding cheat sheet
4. Creates this draft PR if changes are detected
### Manual Sync
You can trigger this workflow manually from the [Actions tab](../../actions/workflows/sync-code-examples.yml).
---
🤖 *This is a draft PR. Review the changes and mark as ready when satisfied.*
labels: |
documentation
automated
code-examples
- name: Summary
run: |
if [[ "${{ steps.check_changes.outputs.changes }}" == "true" ]]; then
echo "✅ Draft PR created with synced code examples"
echo "📝 Review the PR and mark as ready when satisfied"
else
echo "✅ Code examples are already up to date"
echo "ℹ️ No changes needed"
fi