Skip to content

Commit 1981667

Browse files
authored
Have cron job create PR to update notebook outputs (Qiskit#1543)
Each time the fortnightly cron job runs, I usually make a PR updating the notebooks in this repo with the output of the cron job. This PR automates that process. As well as saving some manual work, this also means I can review those PRs too. See #10 for an example of this working.
1 parent 52552f4 commit 1981667

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

.github/workflows/notebook-test-cron.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@ jobs:
4040
git diff --name-only >> $GITHUB_OUTPUT
4141
echo "EOF" >> $GITHUB_OUTPUT
4242
43+
- name: Make pull request with notebook outputs
44+
if: "!cancelled()"
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
run: |
48+
git config user.email "github-actions[bot]@users.noreply.github.com"
49+
git config user.name "github-actions[bot]"
50+
git switch -c actions/cron-${{ github.run_id }}
51+
git commit -am "Re-run notebooks"
52+
git push origin actions/cron-${{ github.run_id }}
53+
gh pr create \
54+
-B main \
55+
-H actions/cron-${{ github.run_id }} \
56+
--title "Update notebook outputs" \
57+
--body "An action recently executed the notebooks in this repo. \
58+
This PR updates all notebooks that ran successfully with the new cell outputs.
59+
> [!NOTE]
60+
> This pull request was created by a GitHub action." \
61+
--reviewer frankharkins
62+
4363
- name: Upload executed notebooks
4464
if: "!cancelled()"
4565
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)