diff --git a/.github/scripts/check_versions.py b/.github/scripts/check_versions.py new file mode 100644 index 00000000..f157d083 --- /dev/null +++ b/.github/scripts/check_versions.py @@ -0,0 +1,42 @@ +import yaml +import requests +import os +import sys + +print("Current Directory:", os.getcwd()) + + +def get_latest_docker_image_version(repo_name): + url = f"https://registry.hub.docker.com/v2/repositories/huskyci/{repo_name}/tags" + response = requests.get(url) + data = response.json() + + # Assuming the first result is the latest + latest_version = data['results'][0]['name'] + return latest_version + + +def main(): + dependencies_are_outdated = False + + with open('api/config.yaml', 'r') as f: + config = yaml.safe_load(f) + + for tool, tool_info in config.items(): + current_version = tool_info['imageTag'] + latest_version = get_latest_docker_image_version( + tool_info['image'].split('/')[-1]) + + if current_version != latest_version: + print( + f"::error::{tool} is outdated. Current: {current_version}, Latest: {latest_version}") + dependencies_are_outdated = True + else: + print(f"{tool} is up-to-date with version {current_version}.") + + if dependencies_are_outdated: + sys.exit(1) + + +if __name__ == "__main__": + main() diff --git a/.github/workflows/tools_version_check.yml b/.github/workflows/tools_version_check.yml new file mode 100644 index 00000000..15b1d3e4 --- /dev/null +++ b/.github/workflows/tools_version_check.yml @@ -0,0 +1,27 @@ +name: Tools Version Checker + +on: + schedule: + - cron: '0 0 * * *' # This will run every day at midnight + workflow_dispatch: + +jobs: + check-versions: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4.1.1 + + - name: Set up Python + uses: actions/setup-python@v4.7.1 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pyyaml requests + + - name: Check tool versions + run: python .github/scripts/check_versions.py