diff --git a/entrypoint.sh b/entrypoint.sh index 7cf4782..91c3f11 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -44,6 +44,23 @@ URI="https://api.github.com" API_HEADER="Accept: application/vnd.github.v3+json" AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}" +# --- CI k8s -------------------------------------------------------------------------- +# When the repository variable CI_K8S_TRIGGER (passed in by the calling workflow) is +# "true", every needs_ci / needs_ci:lite this action adds also starts the matching CI k8s +# workflow. A label added with GITHUB_TOKEN starts no workflow, so it is started with +# workflow_dispatch, which GITHUB_TOKEN may trigger (needs `actions: write`). Never fails +# the action. +ci_k8s_request() { # ci_k8s_request : start a CI k8s run of this PR + [[ "${CI_K8S_TRIGGER:-false}" == "true" ]] || return 0 + 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\":{\"pr\":\"${number}\"}}" \ + "${URI}/repos/${GITHUB_REPOSITORY}/actions/workflows/${1}/dispatches" || true +} +# -------------------------------------------------------------------------------------- + # action action=$(jq --raw-output .action "$GITHUB_EVENT_PATH") comment_body=$(jq --raw-output .comment.body "$GITHUB_EVENT_PATH") @@ -98,6 +115,7 @@ if [[ $comment_body == "shipit" || $comment_body == ":shipit:" || $comment_body done if [[ "$already_verified" == false && "$already_needs_ci" == false ]]; then add_label "needs_ci" + ci_k8s_request "ci_k8s_full.yml" fi if [[ "$already_verified_alt" == false && "$already_needs_ci_alt" == false ]]; then if [[ "$curr_python_version" != "$alt_python_version" ]]; then @@ -129,6 +147,7 @@ if [[ $comment_body == "needs_ci" ]]; then done if [[ "$already_needs_ci" == false ]]; then add_label "needs_ci" + ci_k8s_request "ci_k8s_full.yml" fi if [[ "$already_needs_ci_alt" == false ]]; then if [[ "$curr_python_version" != "$alt_python_version" ]]; then @@ -153,6 +172,7 @@ if [[ $comment_body == "needs_ci:lite" ]]; then done if [[ "$already_needs_ci_lite" == false ]]; then add_label "needs_ci:lite" + ci_k8s_request "ci_k8s_lite.yml" fi fi