From 43f3d1bd7326936415690fdbd03a59a6d9fa5980 Mon Sep 17 00:00:00 2001 From: Aditya Sheth Date: Mon, 19 Oct 2026 15:25:32 +0530 Subject: [PATCH 1/5] Optionally request the ci_k8s labels next to needs_ci Two switches from the calling workflow, CI_FLEET_TRIGGER (default true) and CI_K8S_TRIGGER (default false). When CI_K8S_TRIGGER is true, wherever needs_ci or needs_ci:lite is requested, also add ci_k8s / ci_k8s:lite and start the matching workflow with workflow_dispatch. Same-repository PRs only. Unchanged when unset. Co-Authored-By: Claude Opus 5.5 --- entrypoint.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 7cf4782..66414b6 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -44,6 +44,51 @@ URI="https://api.github.com" API_HEADER="Accept: application/vnd.github.v3+json" AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}" +# --- Which CI to request --------------------------------------------------------------- +# Two switches, "true" or "false", passed in by the calling workflow from repository +# variables: +# CI_FLEET_TRIGGER the fleet CI's labels: needs_ci, needs_ci:lite. Unset = true. +# CI_K8S_TRIGGER CI k8s's labels: ci_k8s, ci_k8s:lite. Unset = false. +fleet_on() { [[ "${CI_FLEET_TRIGGER:-true}" == "true" ]]; } +k8s_on() { [[ "${CI_K8S_TRIGGER:-false}" == "true" ]]; } + +has_label() { # has_label : on the PR as this script read it + local l + for l in $labels; do [[ "$l" == "$1" ]] && return 0; done + return 1 +} + +# A label added with GITHUB_TOKEN starts no workflow, so CI k8s is started with +# workflow_dispatch, which GITHUB_TOKEN may trigger (needs `actions: write`). Same-repo +# PRs only: a fork's code must not run on the CI cluster. Never fails the action. +same_repo_pr() { + local head + head=$(curl -sSL -H "${AUTH_HEADER}" -H "${API_HEADER}" \ + "${URI}/repos/${GITHUB_REPOSITORY}/pulls/${number}" | jq -r '.head.repo.full_name // ""') || return 1 + [[ "$head" == "$GITHUB_REPOSITORY" ]] +} + +dispatch() { # dispatch + local ref + ref=$(jq -r '.repository.default_branch // "master"' "$GITHUB_EVENT_PATH") + curl -sSL -o /dev/null -w "dispatch $1: HTTP %{http_code}\n" \ + -H "${AUTH_HEADER}" -H "${API_HEADER}" -X POST -H "Content-Type: application/json" \ + -d "{\"ref\":\"${ref}\",\"inputs\":${2}}" \ + "${URI}/repos/${GITHUB_REPOSITORY}/actions/workflows/${1}/dispatches" || true +} + +# k8s_request