-
Notifications
You must be signed in to change notification settings - Fork 2
61 lines (50 loc) · 1.75 KB
/
render-notebooks.yml
File metadata and controls
61 lines (50 loc) · 1.75 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
name: Render Notebooks for GitHub
on:
push:
paths:
- '**.ipynb'
pull_request:
branches:
- main
workflow_dispatch: # Allows manual triggering
permissions:
contents: write
pull-requests: write
jobs:
render-notebooks:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref || github.ref_name }} # Explicitly checkout the branch that triggered the workflow
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nbformat nbconvert jupyter
- name: Run conversion script
run: python .github/workflows/convert_notebooks.py
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Commit and push changes
run: |
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: $CURRENT_BRANCH"
# Stage all notebook files
git add "**/*.ipynb"
# Check if there are changes to commit
if git diff --staged --quiet; then
echo "No changes detected in notebooks"
else
echo "Changes detected in notebooks"
git commit -m "Fix notebooks for GitHub compatibility"
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git HEAD:${CURRENT_BRANCH}
echo "Successfully pushed changes"
fi