diff --git a/.github/workflows/notebook-images.yml b/.github/workflows/notebook-images.yml index ef081608..1f10fa35 100644 --- a/.github/workflows/notebook-images.yml +++ b/.github/workflows/notebook-images.yml @@ -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 + diff --git a/examples/generate_notebooks.py b/examples/generate_notebooks.py index c88aa3bc..ba45a139 100644 --- a/examples/generate_notebooks.py +++ b/examples/generate_notebooks.py @@ -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)