Skip to content

Commit 2c060a5

Browse files
authored
Copier update (trigger) (#25)
Pull in fix
1 parent 01e7f0b commit 2c060a5

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier
2-
_commit: v0.0.39
2+
_commit: v0.0.40
33
_src_path: gh:LabAutomationAndScreening/copier-base-template.git
44
description: Copier template for creating Python libraries and executables
55
python_ci_versions:

.github/workflows/dependabot-post-update.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Dependabot Post-Update
22
permissions:
3-
contents: write # grant write access so we can push commits
3+
contents: write # so the commit can be pushed
4+
actions: write # so createWorkflowDispatch can be invoked
45
on:
56
pull_request:
67
types: [opened, synchronize]
@@ -33,8 +34,25 @@ jobs:
3334
# only commit if there are changes
3435
if ! git diff --quiet; then
3536
git add .
36-
git commit -m "chore: apply post-Dependabot script changes"
37+
git commit -m "chore: apply post-Dependabot script changes [dependabot skip]"
3738
git push origin HEAD:${{ github.event.pull_request.head.ref }}
3839
else
3940
echo "No changes to commit"
4041
fi
42+
43+
- 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
44+
uses: actions/[email protected]
45+
with:
46+
github-token: ${{ secrets.GITHUB_TOKEN }}
47+
script: |
48+
const run = context.payload.workflow_run;
49+
const pr = run.pull_requests[0];
50+
if (!pr) {
51+
throw new Error("No pull request linked to this workflow_run event; aborting dispatch.");
52+
}
53+
await github.actions.createWorkflowDispatch({
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
workflow_id: "ci.yaml",
57+
ref: run.head_branch,
58+
});

extensions/context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def hook(self, context: dict[Any, Any]) -> dict[Any, Any]:
4949
context["gha_cache"] = "v4.2.2"
5050
context["gha_upload_artifact"] = "v4.6.2"
5151
context["gha_download_artifact"] = "v4.2.1"
52+
context["gha_github_script"] = "v7.0.1"
5253
context["gha_setup_buildx"] = "v3.10.0"
5354
context["buildx_version"] = "v0.22.0"
5455
context["gha_docker_build_push"] = "v6.15.0"

template/.github/workflows/dependabot-post-update.yaml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Dependabot Post-Update
22
permissions:
3-
contents: write # grant write access so we can push commits
3+
contents: write # so the commit can be pushed
4+
actions: write # so createWorkflowDispatch can be invoked
45
on:
56
pull_request:
67
types: [opened, synchronize]
@@ -33,8 +34,25 @@ jobs:
3334
# only commit if there are changes
3435
if ! git diff --quiet; then
3536
git add .
36-
git commit -m "chore: apply post-Dependabot script changes"
37+
git commit -m "chore: apply post-Dependabot script changes [dependabot skip]"
3738
git push origin HEAD:${{ github.event.pull_request.head.ref }}
3839
else
3940
echo "No changes to commit"
4041
fi
42+
43+
- 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
44+
uses: actions/[email protected]
45+
with:
46+
github-token: ${{ secrets.GITHUB_TOKEN }}
47+
script: |
48+
const run = context.payload.workflow_run;
49+
const pr = run.pull_requests[0];
50+
if (!pr) {
51+
throw new Error("No pull request linked to this workflow_run event; aborting dispatch.");
52+
}
53+
await github.actions.createWorkflowDispatch({
54+
owner: context.repo.owner,
55+
repo: context.repo.repo,
56+
workflow_id: "ci.yaml",
57+
ref: run.head_branch,
58+
});

0 commit comments

Comments
 (0)