From f19829033aa8b41c32244af2752fb638f315deb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Wed, 4 Dec 2024 14:16:34 +0100 Subject: [PATCH] Add check for removed repository (#2880) --- .github/workflows/checks.yml | 20 ++++++++++++++++++++ requirements.txt | 3 ++- scripts/check/removed.py | 22 ++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 scripts/check/removed.py diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 97a2bfc..d5c3681 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -104,6 +104,26 @@ jobs: - name: Run the check run: python3 -m scripts.check.edits + removed: + runs-on: ubuntu-latest + name: Removed repository + steps: + - name: Check out repository + uses: actions/checkout@v4.2.1 + + - name: Set up Python + uses: actions/setup-python@v5.2.0 + with: + python-version-file: ".python-version" + cache: "pip" + cache-dependency-path: "requirements.txt" + + - name: Install dependencies if needed + run: scripts/setup + + - name: Run the check + run: python3 -m scripts.check.removed + hassfest: runs-on: ubuntu-latest name: Hassfest diff --git a/requirements.txt b/requirements.txt index 0caac0e..4cfdbf0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -aiogithubapi==21.11.0 \ No newline at end of file +aiogithubapi==21.11.0 +requests==2.32.3 diff --git a/scripts/check/removed.py b/scripts/check/removed.py new file mode 100644 index 0000000..cca7194 --- /dev/null +++ b/scripts/check/removed.py @@ -0,0 +1,22 @@ +import asyncio +import os +import requests + +CHECKURL = "https://data-v2.hacs.xyz/removed/repositories.json" + + +async def check(): + repo = os.environ["REPOSITORY"].lower() + + try: + removed_repositories = set(x.lower() for x in requests.get(CHECKURL).json()) + if repo in removed_repositories: + exit(f"::error::'{repo}' has been removed from HACS") + except Exception as e: + exit(f"::error::{e}") + + print("Repository not removed from HACS") + + +if __name__ == "__main__": + asyncio.get_event_loop().run_until_complete(check())