Repository navigation
55 lines (47 loc) · 1.97 KB
/
Copy pathgenerate_notebooks.yml
File metadata and controls
55 lines (47 loc) · 1.97 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
name: Generate Example Notebooks
on:
push:
branches:
- main # Or your default branch
paths:
- "examples/**.py"
- "scripts/create-notebooks.sh"
- ".github/workflows/generate_notebooks.yml"
permissions:
contents: write
pull-requests: write
issues: write
jobs:
generate-notebooks:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install the project
run: uv sync --all-extras --dev --locked
- name: Generate Notebooks
id: generate
run: scripts/create-notebooks.sh
- name: Stage generated notebooks
run: |
# Stage generated/updated notebooks, forcing past .gitignore
# The create-pull-request action will commit them if changes exist.
git add --force examples/*.ipynb
- name: Commit and Push Notebooks to 'notebooks' branch
run: |
git config user.name "GitHub Action"
git config user.email "action@github.com"
# Create/switch to the notebooks branch
git checkout -B notebooks
# Add the files again on the new branch (in case checkout unstaged them)
git add --force examples/*.ipynb
# Check if there are staged changes, commit only if there are
git diff --staged --quiet || git commit -m "chore: Generate example notebooks [skip ci]"
# Push to the remote notebooks branch, force pushing is necessary
# as this branch's history is disposable and frequently rewritten.
git push origin notebooks --force