Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/check-caddy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:
id: check_script
env:
DOCKERHUB_REPOSITORY_NAME: ${{ env.DOCKERHUB_REPOSITORY_NAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python scripts/check_caddy_status.py

- name: Trigger Build Workflow if Needed
Expand Down
15 changes: 8 additions & 7 deletions scripts/check_caddy_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
OFFICIAL_CADDY_IMAGE = "library/caddy"
# --- Can be set as a repository secret or variable ---
CUSTOM_IMAGE = os.environ.get('DOCKERHUB_REPOSITORY_NAME', "caddybuilds/caddy-cloudflare")
GITHUB_TOKEN = os.environ.get('GITHUB_TOKEN', "")
# DEPRECATED !!! CHANGE THIS if your tags start with 'v' (e.g., use 'v') !!!
CUSTOM_TAG_PREFIX = ""
# These are the platforms WE want to build and require the OFFICIAL image to have available.
Expand Down Expand Up @@ -63,13 +64,18 @@ def set_action_output(output_name, value):
# Exiting might be safer if outputs are critical
sys.exit(1)


def get_latest_caddy_release():
"""Fetches the latest release tag from the Caddy GitHub repository."""
url = f'https://api.github.com/repos/{GITHUB_REPO}/releases/latest'
log_info(f"Fetching latest release from {url}")
headers = {}
if GITHUB_TOKEN:
headers['Authorization'] = f'token {GITHUB_TOKEN}'
log_info("Using authenticated GitHub API request")
else:
log_info("::warning::No GITHUB_TOKEN found, using unauthenticated request (lower rate limit)")
try:
response = requests.get(url, timeout=30)
response = requests.get(url, headers=headers, timeout=30)
response.raise_for_status()
release = response.json()
tag_name = release.get('tag_name')
Expand All @@ -92,8 +98,6 @@ def get_latest_caddy_release():
log_error(f"Error decoding GitHub API JSON response: {e}")
sys.exit(1)



def check_docker_hub_tag(image_name, tag):
"""Checks if a specific tag exists for a Docker Hub image. Returns tag data or None."""
url = f"https://hub.docker.com/v2/repositories/{image_name}/tags/{tag}"
Expand All @@ -116,8 +120,6 @@ def check_docker_hub_tag(image_name, tag):
log_error(f"Error decoding Docker Hub API response for tag '{tag}' of '{image_name}': {e}. Response: {response.text[:200]}")
return None



def get_platforms_from_tag_data(tag_data):
"""Extracts required linux platform strings from Docker Hub tag API response."""
platforms = set()
Expand Down Expand Up @@ -146,7 +148,6 @@ def get_platforms_from_tag_data(tag_data):

return platforms


def main():
start_time = datetime.now(timezone.utc)
log_info(f"--- Starting Caddy Check at {start_time.isoformat()} ---")
Expand Down