Check Domains #29
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: | |
Test: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
domain: ["ultralytics.com", "ultralitics.com", "ultralytics.ai", "ultralytics.app", "ultralytics.eu", "ultralytics.es", "ultralytics.io", "ultralytics.net", "ultralytics.org", "yolov5.com", "pjreddie.org", "pjreddie.net"] | |
prefix: ["www.", ""] | |
steps: | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests | |
- name: Check domain redirections | |
shell: python | |
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. | |
""" | |
url = f"https://{prefix}{domain}" | |
print(f"\nChecking {url}") | |
for attempt in range(max_attempts): | |
try: | |
response = requests.get(url, allow_redirects=True) | |
response.raise_for_status() | |
final_url = response.url | |
if "ultralytics.com" in final_url and response.status_code == 200: | |
print("Success ✅") | |
return True | |
except requests.RequestException as e: | |
print(f"Error: {e}") | |
if attempt == max_attempts - 1: | |
print(f"Failed after {max_attempts} attempts ❌.") | |
return False | |
return False | |
success = check_domain_redirection('${{ matrix.domain }}', '${{ matrix.prefix }}') | |
if not success: | |
raise Exception(f"Domain check failed for ${{ matrix.domain }} with prefix '${{ matrix.prefix }}'") | |
Summary: | |
runs-on: ubuntu-latest | |
needs: [Test] # Add job names that you want to check for failure | |
if: always() # This ensures the job runs even if previous jobs fail | |
steps: | |
- name: Check for failure and notify | |
if: needs.Test.result == 'failure' && github.repository == 'ultralytics/docs' && (github.event_name == 'schedule' || github.event_name == 'push') | |
uses: slackapi/[email protected] | |
with: | |
payload: | | |
{"text": "<!channel> GitHub Actions error for ${{ github.workflow }} ❌\n\n\n*Repository:* https://github.com/${{ github.repository }}\n*Action:* https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*Author:* ${{ github.actor }}\n*Event:* ${{ github.event_name }}\n"} | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_WEBSITE }} |