Skip to content

workflows, ci_scripts: add automation logic from wheel_builder #1

workflows, ci_scripts: add automation logic from wheel_builder

workflows, ci_scripts: add automation logic from wheel_builder #1

Workflow file for this run

# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
name: PR package build trigger
on:
pull_request:
types: [opened, edited, synchronize, reopened]
permissions:
contents: read
actions: write
pull-requests: read
jobs:
dispatch-triggers:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.body, 'Trigger:')
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Dispatch build/test workflows for Trigger directives
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_BODY: ${{ github.event.pull_request.body }}
HEAD_REF: ${{ github.event.pull_request.head.ref }}
HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
BASE_REPO: ${{ github.repository }}
run: |
set -euo pipefail
if [ "$HEAD_REPO" != "$BASE_REPO" ]; then
echo "PR from fork ($HEAD_REPO); cannot dispatch workflows against fork ref. Skipping."
exit 0
fi
triggers=$(printf '%s\n' "$PR_BODY" | grep -oE '^Trigger:[[:space:]]*[^[:space:]]+' || true)
if [ -z "$triggers" ]; then
echo "No Trigger: directives found."
exit 0
fi
printf '%s\n' "$triggers" | while IFS= read -r line; do
directive=${line#Trigger:}
directive=${directive# }
pkg=${directive%:*}
ref=${directive#*:}
if [ -z "$pkg" ] || [ -z "$ref" ] || [ "$pkg" = "$ref" ]; then
echo "Skipping malformed directive: $line"
continue
fi
build_wf=".github/workflows/build-${pkg}.yml"
test_wf=".github/workflows/test-${pkg}.yml"
if [ ! -f "$build_wf" ]; then
echo "No build workflow for $pkg at $build_wf; skipping."
continue
fi
echo "Dispatching build-${pkg}.yml on $HEAD_REF with version=$ref"
gh workflow run "build-${pkg}.yml" --ref "$HEAD_REF" -f "version=$ref"
if [ -f "$test_wf" ]; then
echo "Dispatching test-${pkg}.yml on $HEAD_REF with version=$ref"
gh workflow run "test-${pkg}.yml" --ref "$HEAD_REF" -f "version=$ref"
fi
done