1717
1818"""
1919Auxiliary functions to interact with the GitHub REST API.
20+
21+ Set the GITHUB_REPO environment variable to override the target repository
22+ (e.g. "myuser/kafka" to test against a personal fork).
23+
24+ Set GITHUB_DRY_RUN=true to print API calls without executing them.
2025"""
2126
2227import json
28+ import os
2329import urllib .request
2430
2531from runtime import fail
2632
2733GITHUB_API_URL = "https://api.github.com"
28- GITHUB_REPO = "apache/kafka"
34+ GITHUB_REPO = os .environ .get ("GITHUB_REPO" , "apache/kafka" )
35+ DRY_RUN = os .environ .get ("GITHUB_DRY_RUN" , "" ).lower () in ("true" , "1" , "yes" )
2936
3037
3138def _api_request (token , method , path , body = None ):
3239 """
3340 Make an authenticated request to the GitHub REST API.
41+ In dry-run mode, prints the request details without executing.
3442 """
3543 url = f"{ GITHUB_API_URL } { path } "
44+
45+ if DRY_RUN :
46+ print (f"[DRY RUN] { method } { url } " )
47+ if body :
48+ print (f"[DRY RUN] Body: { json .dumps (body , indent = 2 )} " )
49+ return None
50+
3651 data = json .dumps (body ).encode ("utf-8" ) if body else None
3752 req = urllib .request .Request (url , data = data , method = method )
3853 req .add_header ("Accept" , "application/vnd.github.v3+json" )
@@ -56,7 +71,7 @@ def trigger_workflow(token, workflow_file, ref, inputs):
5671 """
5772 path = f"/repos/{ GITHUB_REPO } /actions/workflows/{ workflow_file } /dispatches"
5873 body = {"ref" : ref , "inputs" : inputs }
59- print (f"Triggering workflow { workflow_file } with inputs: { json .dumps (inputs )} " )
74+ print (f"Triggering workflow { workflow_file } on { GITHUB_REPO } with inputs: { json .dumps (inputs )} " )
6075 _api_request (token , "POST" , path , body )
6176 print (f"Successfully triggered { workflow_file } " )
6277
@@ -65,6 +80,10 @@ def trigger_docker_build_test(token, ref, image_type, kafka_url):
6580 """
6681 Trigger the Docker Build Test workflow for the given image type.
6782 """
83+ print (f"\n --- Docker Build Test ({ image_type } ) ---" )
84+ print (f" Image type : { image_type } " )
85+ print (f" Branch/ref : { ref } " )
86+ print (f" Kafka URL : { kafka_url } " )
6887 trigger_workflow (token , "docker_build_and_test.yml" , ref , {
6988 "image_type" : image_type ,
7089 "kafka_url" : kafka_url ,
@@ -75,6 +94,11 @@ def trigger_docker_rc_release(token, ref, image_type, rc_docker_image, kafka_url
7594 """
7695 Trigger the Docker RC Release workflow for the given image type.
7796 """
97+ print (f"\n --- Docker RC Release ({ image_type } ) ---" )
98+ print (f" Image type : { image_type } " )
99+ print (f" Docker image : { rc_docker_image } " )
100+ print (f" Branch/ref : { ref } " )
101+ print (f" Kafka URL : { kafka_url } " )
78102 trigger_workflow (token , "docker_rc_release.yml" , ref , {
79103 "image_type" : image_type ,
80104 "rc_docker_image" : rc_docker_image ,
0 commit comments