Skip to content

Commit d3fb16e

Browse files
committed
workflows: pr-trigger: add
Add a workflow for triggering workflows named "build-<package>.yml" (and if present, "test-<package>.yml") with desired release tags for a given package. For automated upgrade checks and manual changes, this means that the tags only need to be specified in the PR description when opened. This is based on the process in wheel_builder where a child pipeline would be generated automatically when a merge request was submitted with one or more package version tags listed as e.g. "Trigger: polars:py-1.42.1" in the MR description. AI-Generated: Uses Claude Code Sonnet 4.7 Signed-off-by: Trevor Gamblin <tgamblin@baylibre.com>
1 parent 0cf55eb commit d3fb16e

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

.github/workflows/pr-trigger.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# SPDX-FileCopyrightText: 2026 The RISE Project
2+
# SPDX-License-Identifier: MIT
3+
4+
name: PR package build trigger
5+
6+
on:
7+
pull_request:
8+
types: [opened, edited, synchronize, reopened]
9+
10+
permissions:
11+
contents: read
12+
actions: write
13+
pull-requests: read
14+
15+
jobs:
16+
dispatch-triggers:
17+
runs-on: ubuntu-latest
18+
if: contains(github.event.pull_request.body, 'Trigger:')
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
package_version: ${{ github.event.pull_request.head.sha }}
23+
24+
- name: Dispatch build/test workflows for Trigger directives
25+
env:
26+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
PR_BODY: ${{ github.event.pull_request.body }}
28+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
29+
HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
30+
BASE_REPO: ${{ github.repository }}
31+
run: |
32+
set -euo pipefail
33+
34+
if [ "$HEAD_REPO" != "$BASE_REPO" ]; then
35+
echo "PR from fork ($HEAD_REPO); cannot dispatch workflows against fork ref. Skipping."
36+
exit 0
37+
fi
38+
39+
triggers=$(printf '%s\n' "$PR_BODY" | grep -oE '^Trigger:[[:space:]]*[^[:space:]]+' || true)
40+
41+
if [ -z "$triggers" ]; then
42+
echo "No Trigger: directives found."
43+
exit 0
44+
fi
45+
46+
printf '%s\n' "$triggers" | while IFS= read -r line; do
47+
directive=${line#Trigger:}
48+
directive=${directive# }
49+
package_name=${directive%:*}
50+
package_version=${directive#*:}
51+
52+
if [ -z "$package_name" ] || [ -z "$package_version" ] || [ "$package_name" = "$package_version" ]; then
53+
echo "Skipping malformed directive: $line"
54+
continue
55+
fi
56+
57+
build_wf=".github/workflows/build-${package_name}.yml"
58+
test_wf=".github/workflows/test-${package_name}.yml"
59+
60+
if [ ! -f "$build_wf" ]; then
61+
echo "No build workflow for $package_name at $build_wf; skipping."
62+
continue
63+
fi
64+
65+
echo "Dispatching build-${package_name}.yml on $HEAD_REF with version=$package_version"
66+
gh workflow run "build-${package_name}.yml" --ref "$HEAD_REF" -f "version=$package_version"
67+
68+
if [ -f "$test_wf" ]; then
69+
echo "Dispatching test-${package_name}.yml on $HEAD_REF with version=$package_version"
70+
gh workflow run "test-${package_name}.yml" --ref "$HEAD_REF" -f "version=$package_version"
71+
fi
72+
done

0 commit comments

Comments
 (0)