Check Domains #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ultralytics YOLO 🚀, AGPL-3.0 license | |
# Ultralics website domain checks | |
name: Check Domains | |
on: | |
schedule: | |
# Runs every day at 05:00 UTC | |
- cron: '0 5 * * *' | |
workflow_dispatch: | |
jobs: | |
checks: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests | |
- name: Check domain redirections | |
run: | | |
import requests | |
def check_domain_redirection(domain, prefix, max_attempts=3): | |
"""Check if the given domain redirects to ultralytics.com correctly, with up to 3 retries using a for-loop.""" | |
for attempt in range(max_attempts): | |
try: | |
url = f'https://{prefix}{domain}' | |
print(f'Attempt {attempt + 1}: Checking {url}') | |
response = requests.get(url, allow_redirects=True) | |
final_url = response.url | |
if 'ultralytics.com' in final_url and response.status_code == 200: | |
print(f'{domain} redirects correctly to ultralytics.com ✅') | |
return True | |
else: | |
print(f'{domain} redirect issue. Final URL: {final_url}, Response code: {response.status_code}') | |
return False | |
except requests.RequestException as e: | |
print(f'Error checking {domain}: {e}') | |
if attempt == max_attempts - 1: | |
print(f'Failed to check {domain} after {max_attempts} attempts ❌.') | |
return False | |
domains = [ | |
'ultralitics.com', | |
'ultralytics.ai', | |
'ultralytics.app', | |
'ultralytics.eu', | |
'ultralytics.es', | |
'ultralytics.io', | |
'ultralytics.net', | |
'ultralytics.org', | |
'yolov5.com', | |
] | |
for prefix in ['www.', '']: | |
for domain in domains: | |
check_domain_redirection(domain, prefix) |