From 6cda3072385030bc91f1a55b4044662a06b2316e Mon Sep 17 00:00:00 2001 From: Eli Fine Date: Fri, 9 May 2025 12:19:17 +0000 Subject: [PATCH 1/3] coip --- .copier-answers.yml | 2 +- .github/workflows/dependabot-post-update.yaml | 23 +++++++++++++++++-- extensions/context.py | 1 + .../workflows/dependabot-post-update.yaml | 23 +++++++++++++++++-- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/.copier-answers.yml b/.copier-answers.yml index 0374019c..85b20bdd 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: v0.0.39 +_commit: v0.0.39-2-g5e29bf1 _src_path: gh:LabAutomationAndScreening/copier-base-template.git description: Copier template for creating Python libraries and executables python_ci_versions: diff --git a/.github/workflows/dependabot-post-update.yaml b/.github/workflows/dependabot-post-update.yaml index 68da3da2..edcb53ad 100644 --- a/.github/workflows/dependabot-post-update.yaml +++ b/.github/workflows/dependabot-post-update.yaml @@ -1,6 +1,7 @@ name: Dependabot Post-Update permissions: - contents: write # grant write access so we can push commits + contents: write # so the commit can be pushed + actions: write # so createWorkflowDispatch can be invoked on: pull_request: types: [opened, synchronize] @@ -33,8 +34,26 @@ jobs: # only commit if there are changes if ! git diff --quiet; then git add . - git commit -m "chore: apply post-Dependabot script changes" + git commit -m "chore: apply post-Dependabot script changes [dependabot skip]" git push origin HEAD:${{ github.event.pull_request.head.ref }} else echo "No changes to commit" fi + + - name: Dispatch CI on PR branch # pushes done by GITHUB_TOKEN don't trigger workflows, so we have to restart the CI job manually + uses: actions/github-script@v7.0.1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const run = context.payload.workflow_run; + const pr = run.pull_requests[0]; + if (!pr) { + console.log("No PR linked to this run, skipping."); + return; + } + await github.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: "ci.yaml", + ref: run.head_branch, + }); diff --git a/extensions/context.py b/extensions/context.py index 7623a061..f0186b7c 100644 --- a/extensions/context.py +++ b/extensions/context.py @@ -49,6 +49,7 @@ def hook(self, context: dict[Any, Any]) -> dict[Any, Any]: context["gha_cache"] = "v4.2.2" context["gha_upload_artifact"] = "v4.6.2" context["gha_download_artifact"] = "v4.2.1" + context["gha_github_script"] = "v7.0.1" context["gha_setup_buildx"] = "v3.10.0" context["buildx_version"] = "v0.22.0" context["gha_docker_build_push"] = "v6.15.0" diff --git a/template/.github/workflows/dependabot-post-update.yaml b/template/.github/workflows/dependabot-post-update.yaml index 68da3da2..edcb53ad 100644 --- a/template/.github/workflows/dependabot-post-update.yaml +++ b/template/.github/workflows/dependabot-post-update.yaml @@ -1,6 +1,7 @@ name: Dependabot Post-Update permissions: - contents: write # grant write access so we can push commits + contents: write # so the commit can be pushed + actions: write # so createWorkflowDispatch can be invoked on: pull_request: types: [opened, synchronize] @@ -33,8 +34,26 @@ jobs: # only commit if there are changes if ! git diff --quiet; then git add . - git commit -m "chore: apply post-Dependabot script changes" + git commit -m "chore: apply post-Dependabot script changes [dependabot skip]" git push origin HEAD:${{ github.event.pull_request.head.ref }} else echo "No changes to commit" fi + + - name: Dispatch CI on PR branch # pushes done by GITHUB_TOKEN don't trigger workflows, so we have to restart the CI job manually + uses: actions/github-script@v7.0.1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const run = context.payload.workflow_run; + const pr = run.pull_requests[0]; + if (!pr) { + console.log("No PR linked to this run, skipping."); + return; + } + await github.actions.createWorkflowDispatch({ + owner: context.repo.owner, + repo: context.repo.repo, + workflow_id: "ci.yaml", + ref: run.head_branch, + }); From 6088e285b4b4e2f428b84973279823215f755861 Mon Sep 17 00:00:00 2001 From: Eli Fine Date: Fri, 9 May 2025 12:23:27 +0000 Subject: [PATCH 2/3] copier --- .copier-answers.yml | 2 +- .github/workflows/dependabot-post-update.yaml | 3 +-- template/.github/workflows/dependabot-post-update.yaml | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.copier-answers.yml b/.copier-answers.yml index 85b20bdd..c276bbbd 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: v0.0.39-2-g5e29bf1 +_commit: v0.0.39-3-g8a758fa _src_path: gh:LabAutomationAndScreening/copier-base-template.git description: Copier template for creating Python libraries and executables python_ci_versions: diff --git a/.github/workflows/dependabot-post-update.yaml b/.github/workflows/dependabot-post-update.yaml index edcb53ad..843b137c 100644 --- a/.github/workflows/dependabot-post-update.yaml +++ b/.github/workflows/dependabot-post-update.yaml @@ -48,8 +48,7 @@ jobs: const run = context.payload.workflow_run; const pr = run.pull_requests[0]; if (!pr) { - console.log("No PR linked to this run, skipping."); - return; + throw new Error("No pull request linked to this workflow_run event; aborting dispatch."); } await github.actions.createWorkflowDispatch({ owner: context.repo.owner, diff --git a/template/.github/workflows/dependabot-post-update.yaml b/template/.github/workflows/dependabot-post-update.yaml index edcb53ad..843b137c 100644 --- a/template/.github/workflows/dependabot-post-update.yaml +++ b/template/.github/workflows/dependabot-post-update.yaml @@ -48,8 +48,7 @@ jobs: const run = context.payload.workflow_run; const pr = run.pull_requests[0]; if (!pr) { - console.log("No PR linked to this run, skipping."); - return; + throw new Error("No pull request linked to this workflow_run event; aborting dispatch."); } await github.actions.createWorkflowDispatch({ owner: context.repo.owner, From aaee5b742b3f2832b24d6bedfa06cc38002cd05d Mon Sep 17 00:00:00 2001 From: Eli Fine Date: Fri, 9 May 2025 12:27:47 +0000 Subject: [PATCH 3/3] tag --- .copier-answers.yml | 2 +- .github/workflows/dependabot-post-update.yaml | 2 +- template/.github/workflows/dependabot-post-update.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.copier-answers.yml b/.copier-answers.yml index c276bbbd..cc008633 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier -_commit: v0.0.39-3-g8a758fa +_commit: v0.0.40 _src_path: gh:LabAutomationAndScreening/copier-base-template.git description: Copier template for creating Python libraries and executables python_ci_versions: diff --git a/.github/workflows/dependabot-post-update.yaml b/.github/workflows/dependabot-post-update.yaml index 843b137c..4a6e7f3f 100644 --- a/.github/workflows/dependabot-post-update.yaml +++ b/.github/workflows/dependabot-post-update.yaml @@ -40,7 +40,7 @@ jobs: echo "No changes to commit" fi - - name: Dispatch CI on PR branch # pushes done by GITHUB_TOKEN don't trigger workflows, so we have to restart the CI job manually + - name: Dispatch CI on PR branch # pushes done by GITHUB_TOKEN don't trigger workflows, so we have to restart the CI job manually, see https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow uses: actions/github-script@v7.0.1 with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/template/.github/workflows/dependabot-post-update.yaml b/template/.github/workflows/dependabot-post-update.yaml index 843b137c..4a6e7f3f 100644 --- a/template/.github/workflows/dependabot-post-update.yaml +++ b/template/.github/workflows/dependabot-post-update.yaml @@ -40,7 +40,7 @@ jobs: echo "No changes to commit" fi - - name: Dispatch CI on PR branch # pushes done by GITHUB_TOKEN don't trigger workflows, so we have to restart the CI job manually + - name: Dispatch CI on PR branch # pushes done by GITHUB_TOKEN don't trigger workflows, so we have to restart the CI job manually, see https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow uses: actions/github-script@v7.0.1 with: github-token: ${{ secrets.GITHUB_TOKEN }}