Skip to content

Commit 7faaa03

Browse files
authored
Merge pull request #1 from fire2a/to_python
jupytext added
2 parents 3908207 + d544bcf commit 7faaa03

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/jupytext.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Convert Jupyter Notebooks to Python Scripts
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
convert_notebooks:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
14+
- name: Install Jupytext
15+
run: pip install jupytext black
16+
17+
- name: Convert notebooks to formatted Python scripts
18+
run: |
19+
for notebook in $(find . -name "*.ipynb"); do
20+
jupytext --to py:percent "$notebook"
21+
py_file="${notebook%.ipynb}.py"
22+
if [ -f "$py_file" ]; then
23+
black --line-length 120 "$py_file"
24+
fi
25+
done
26+
27+
- name: Get the last commit message
28+
id: get_commit_message
29+
run: echo "::set-output name=message::$(git log -1 --pretty=%B)"
30+
31+
- name: Commit changes
32+
run: |
33+
git config --global user.name "github-actions[bot]"
34+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
35+
git add .
36+
git commit -m "nb2py: ${{ steps.get_commit_message.outputs.message }}"
37+
git push
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)