Skip to content

Commit a1e1e40

Browse files
authored
Update sync.yml
1 parent cb10750 commit a1e1e40

1 file changed

Lines changed: 28 additions & 12 deletions

File tree

.github/workflows/sync.yml

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,39 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- name: Checkout main branch
13+
- name: Checkout repository
1414
uses: actions/checkout@v4
1515
with:
16-
fetch-depth: 0
16+
fetch-depth: 0 # Fetch full history to allow branch switching
1717

18-
- name: Fetch JupyterBook branch
18+
- name: Fetch all branches
1919
run: |
20-
git fetch origin jupyterbook:jupyterbook
20+
git fetch --all
2121
22-
- name: Checkout JupyterBook branch
22+
- name: Switch to jupyterbook branch
2323
run: |
24-
git checkout jupyterbook
24+
if git rev-parse --verify origin/jupyterbook; then
25+
git checkout jupyterbook
26+
else
27+
echo "Branch 'jupyterbook' does not exist. Creating it..."
28+
git checkout -b jupyterbook
29+
fi
2530
26-
- name: Copy data, figures, and notebooks from main
31+
- name: Sync files from main branch
2732
run: |
2833
git checkout main -- data figures notebooks
2934
git add data figures notebooks
3035
36+
- name: Verify copied files
37+
run: |
38+
echo "Verifying copied directories..."
39+
ls -la data
40+
ls -la figures
41+
ls -la notebooks
42+
3143
- name: Generate _toc.yml
3244
run: |
45+
echo "Generating _toc.yml..."
3346
cat <<EOF > _toc.yml
3447
format: jb-book
3548
root: intro
@@ -43,29 +56,32 @@ jobs:
4356
EOF
4457
4558
for file in notebooks/L0_*.ipynb; do
46-
echo " - file: $file" >> _toc.yml
59+
[ -e "$file" ] && echo " - file: $file" >> _toc.yml
4760
done
4861
4962
echo " - caption: Basic Functionalities" >> _toc.yml
5063
echo " chapters:" >> _toc.yml
5164
for file in notebooks/L1_*.ipynb; do
52-
echo " - file: $file" >> _toc.yml
65+
[ -e "$file" ] && echo " - file: $file" >> _toc.yml
5366
done
5467
5568
echo " - caption: Advanced Querying using SPARQL" >> _toc.yml
5669
echo " chapters:" >> _toc.yml
5770
for file in notebooks/L2_*.ipynb; do
58-
echo " - file: $file" >> _toc.yml
71+
[ -e "$file" ] && echo " - file: $file" >> _toc.yml
5972
done
6073
6174
echo " - caption: Editing LiPD files" >> _toc.yml
6275
echo " chapters:" >> _toc.yml
6376
for file in notebooks/L3_*.ipynb; do
64-
echo " - file: $file" >> _toc.yml
77+
[ -e "$file" ] && echo " - file: $file" >> _toc.yml
6578
done
6679
80+
- name: Show _toc.yml contents
81+
run: cat _toc.yml
82+
6783
- name: Commit and push changes
6884
run: |
6985
git add _toc.yml
70-
git commit -m "Sync notebooks and update _toc.yml" || echo "No changes to commit"
86+
git commit -m "Sync files and update _toc.yml" || echo "No changes to commit"
7187
git push origin jupyterbook

0 commit comments

Comments
 (0)