1010OFFICIAL_CADDY_IMAGE = "library/caddy"
1111# --- Can be set as a repository secret or variable ---
1212CUSTOM_IMAGE = os .environ .get ('DOCKERHUB_REPOSITORY_NAME' , "caddybuilds/caddy-cloudflare" )
13+ GITHUB_TOKEN = os .environ .get ('GITHUB_TOKEN' , "" )
1314# DEPRECATED !!! CHANGE THIS if your tags start with 'v' (e.g., use 'v') !!!
1415CUSTOM_TAG_PREFIX = ""
1516# These are the platforms WE want to build and require the OFFICIAL image to have available.
@@ -63,13 +64,18 @@ def set_action_output(output_name, value):
6364 # Exiting might be safer if outputs are critical
6465 sys .exit (1 )
6566
66-
6767def get_latest_caddy_release ():
6868 """Fetches the latest release tag from the Caddy GitHub repository."""
6969 url = f'https://api.github.com/repos/{ GITHUB_REPO } /releases/latest'
7070 log_info (f"Fetching latest release from { url } " )
71+ headers = {}
72+ if GITHUB_TOKEN :
73+ headers ['Authorization' ] = f'token { GITHUB_TOKEN } '
74+ log_info ("Using authenticated GitHub API request" )
75+ else :
76+ log_info ("::warning::No GITHUB_TOKEN found, using unauthenticated request (lower rate limit)" )
7177 try :
72- response = requests .get (url , timeout = 30 )
78+ response = requests .get (url , headers = headers , timeout = 30 )
7379 response .raise_for_status ()
7480 release = response .json ()
7581 tag_name = release .get ('tag_name' )
@@ -92,8 +98,6 @@ def get_latest_caddy_release():
9298 log_error (f"Error decoding GitHub API JSON response: { e } " )
9399 sys .exit (1 )
94100
95-
96-
97101def check_docker_hub_tag (image_name , tag ):
98102 """Checks if a specific tag exists for a Docker Hub image. Returns tag data or None."""
99103 url = f"https://hub.docker.com/v2/repositories/{ image_name } /tags/{ tag } "
@@ -116,8 +120,6 @@ def check_docker_hub_tag(image_name, tag):
116120 log_error (f"Error decoding Docker Hub API response for tag '{ tag } ' of '{ image_name } ': { e } . Response: { response .text [:200 ]} " )
117121 return None
118122
119-
120-
121123def get_platforms_from_tag_data (tag_data ):
122124 """Extracts required linux platform strings from Docker Hub tag API response."""
123125 platforms = set ()
@@ -146,7 +148,6 @@ def get_platforms_from_tag_data(tag_data):
146148
147149 return platforms
148150
149-
150151def main ():
151152 start_time = datetime .now (timezone .utc )
152153 log_info (f"--- Starting Caddy Check at { start_time .isoformat ()} ---" )
0 commit comments