Skip to content

Commit

Permalink
add action to push notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
mscroggs committed Oct 1, 2024
1 parent 991d3a6 commit c3df674
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/workflows/notebook-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,28 @@ jobs:
push: true
tags: bempp/cl-notebook-numba:latest
target: numba-lab
upload-notebooks:
permissions:
id-token: write
contents: write
name: Generate and upload example notebooks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Generate notebooks
run: python examples/generate_notebooks.py

- name: Push to GitHub
run: |
cd examples/notebooks
git init
git checkout -b notebooks
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "Notebook examples"
git remote add origin https://oauth2:${{ secrets.GITHUB_TOKEN }}@github.com/bempp/bempp-cl.git
git push -u origin notebooks --force
3 changes: 2 additions & 1 deletion examples/generate_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
scripts = []
for dir in ["laplace", "helmholtz", "maxwell", "other"]:
notebook_subdir = os.path.join(notebook_dir, dir)
os.mkdir(notebook_subdir)
path = os.path.join(os.path.dirname(os.path.realpath(__file__)), dir)
os.mkdir(notebook_subdir)
os.system(f"cp {path}/*.png {notebook_subdir}")
for i in os.listdir(path):
if i.endswith(".py"):
file = os.path.join(path, i)
Expand Down

0 comments on commit c3df674

Please sign in to comment.