Skip to content

Commit 380a04a

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 4ba8556 commit 380a04a

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

.github/workflows/pr-trigger.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
# Normalize: build workflows prepend `v` to the version themselves
58+
# (e.g. `ref: v${{ env.NUMPY_VERSION }}`). Strip any leading v/V
59+
# in the directive so `Trigger: numpy:v2.5.1` and
60+
# `Trigger: numpy:2.5.1` behave identically.
61+
package_version=${package_version#[vV]}
62+
63+
build_wf=".github/workflows/build-${package_name}.yml"
64+
test_wf=".github/workflows/test-${package_name}.yml"
65+
66+
if [ ! -f "$build_wf" ]; then
67+
echo "No build workflow for $package_name at $build_wf; skipping."
68+
continue
69+
fi
70+
71+
echo "Dispatching build-${package_name}.yml on $HEAD_REF with version=$package_version"
72+
gh workflow run "build-${package_name}.yml" --ref "$HEAD_REF" -f "version=$package_version"
73+
74+
if [ -f "$test_wf" ]; then
75+
echo "Dispatching test-${package_name}.yml on $HEAD_REF with version=$package_version"
76+
gh workflow run "test-${package_name}.yml" --ref "$HEAD_REF" -f "version=$package_version"
77+
fi
78+
done

0 commit comments

Comments
 (0)