Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: v0.0.39
_commit: v0.0.40
_src_path: gh:LabAutomationAndScreening/copier-base-template.git
description: Copier template for creating Python libraries and executables
python_ci_versions:
Expand Down
22 changes: 20 additions & 2 deletions .github/workflows/dependabot-post-update.yaml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -33,8 +34,25 @@ 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, 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 }}
script: |
const run = context.payload.workflow_run;
const pr = run.pull_requests[0];
if (!pr) {
throw new Error("No pull request linked to this workflow_run event; aborting dispatch.");
}
await github.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "ci.yaml",
ref: run.head_branch,
});
1 change: 1 addition & 0 deletions extensions/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
22 changes: 20 additions & 2 deletions template/.github/workflows/dependabot-post-update.yaml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -33,8 +34,25 @@ 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, 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 }}
script: |
Copy link

Copilot AI May 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure 'context.payload.workflow_run' is reliably defined before accessing its properties to prevent potential runtime exceptions; consider adding a guard clause if this scenario can occur.

Suggested change
script: |
script: |
if (!context.payload.workflow_run) {
throw new Error("workflow_run is not defined in the event payload; aborting dispatch.");
}

Copilot uses AI. Check for mistakes.
const run = context.payload.workflow_run;
const pr = run.pull_requests[0];
if (!pr) {
throw new Error("No pull request linked to this workflow_run event; aborting dispatch.");
}
await github.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "ci.yaml",
ref: run.head_branch,
});