|
6 | 6 | workflow_dispatch: |
7 | 7 | push: |
8 | 8 | paths: |
9 | | - - 'tests/test-gglite.qmd' |
10 | | - - 'tests/test-gglite.ipynb' |
| 9 | + - 'tests/*.qmd' |
| 10 | + - 'tests/*.ipynb' |
| 11 | + - 'tests/*.py' |
11 | 12 | pull_request: |
12 | 13 | paths: |
13 | | - - 'tests/test-gglite.qmd' |
14 | | - - 'tests/test-gglite.ipynb' |
| 14 | + - 'tests/*.qmd' |
| 15 | + - 'tests/*.ipynb' |
| 16 | + - 'tests/*.py' |
15 | 17 |
|
16 | | -permissions: read-all |
| 18 | +permissions: |
| 19 | + contents: write |
| 20 | + pull-requests: write |
17 | 21 |
|
18 | 22 | jobs: |
19 | 23 | test: |
@@ -57,10 +61,36 @@ jobs: |
57 | 61 | env: |
58 | 62 | SCREENSHOT_PATH: /tmp/jupyter-test.png |
59 | 63 |
|
60 | | - - name: Upload screenshots |
| 64 | + - name: Open PR to update notebook if outputs changed (main only) |
| 65 | + if: github.ref == 'refs/heads/main' |
| 66 | + env: |
| 67 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 68 | + run: | |
| 69 | + python tests/normalize-notebook.py \ |
| 70 | + /tmp/test-gglite-executed.ipynb tests/test-gglite.ipynb |
| 71 | + if git diff --quiet tests/test-gglite.ipynb; then |
| 72 | + echo "Notebook outputs unchanged." |
| 73 | + else |
| 74 | + BRANCH="auto/update-notebook-$(date +%Y%m%d%H%M%S)" |
| 75 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 76 | + git config user.name "github-actions[bot]" |
| 77 | + git checkout -b "$BRANCH" |
| 78 | + git add tests/test-gglite.ipynb |
| 79 | + git commit -m "Update notebook outputs" |
| 80 | + git push origin "$BRANCH" |
| 81 | + gh pr create \ |
| 82 | + --title "Update notebook outputs" \ |
| 83 | + --body "Automated update of notebook cell outputs after execution on main." \ |
| 84 | + --base main --head "$BRANCH" |
| 85 | + fi |
| 86 | +
|
| 87 | + - name: Upload artifacts |
61 | 88 | if: always() |
62 | 89 | uses: actions/upload-artifact@HEAD |
63 | 90 | with: |
64 | | - name: browser-screenshots |
65 | | - path: /tmp/*.png |
| 91 | + name: test-outputs |
| 92 | + path: | |
| 93 | + /tmp/*.png |
| 94 | + tests/test-gglite.html |
| 95 | + /tmp/test-gglite-executed.ipynb |
66 | 96 |
|
0 commit comments