File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed
Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Validate and Fix Notebook
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - main
7+ push :
8+ branches :
9+ - main
10+
11+ permissions :
12+ contents : write
13+
14+ jobs :
15+ validate-and-fix-notebook :
16+ runs-on : ubuntu-latest
17+
18+ steps :
19+ - name : Checkout repository
20+ uses : actions/checkout@v4
21+ with :
22+ fetch-depth : 0
23+
24+ - name : Set up Python
25+ uses : actions/setup-python@v4
26+ with :
27+ python-version : ' 3.x'
28+
29+ - name : Install Jupyter and nbformat
30+ run : |
31+ pip install jupyter nbformat
32+
33+ - name : Validate and Fix Notebook
34+ run : |
35+ python -c "
36+ import nbformat
37+ import glob
38+ for file in glob.glob('**/*.ypyb', recursive=True):
39+ with open(file, 'r') as f:
40+ nb = nbformat.read(f, as_version=4)
41+ nbformat.validate(nb)
42+ if 'application/vnd.beylor-adapt+notebook' not in nb.metadata:
43+ nb.metadata['application/vnd.beylor-adapt+notebook'] = {'version': '1.0'}
44+ with open(file, 'w') as f:
45+ nbformat.write(nb, f)
46+ "
47+
48+ - name : Configure Git
49+ run : |
50+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
51+ git config --global user.name "github-actions[bot]"
52+
53+ - name : Commit changes
54+ run : |
55+ git add -A
56+ git commit -m "Fix notebook format issues" || echo "No changes to commit"
57+ git push origin HEAD:${{ github.event.pull_request.head.ref }}
You can’t perform that action at this time.
0 commit comments