diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index a6d8a08..8a26db5 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -153,6 +153,30 @@ jobs: env: REPOSITORY: ${{needs.preflight.outputs.repository}} + existing: + runs-on: ubuntu-latest + name: Existing repository + needs: preflight + if: needs.preflight.outputs.removal != 'true' + steps: + - name: Check out repository + uses: actions/checkout@v5.0.0 + + - name: Set up Python + uses: actions/setup-python@v6.0.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.existing + env: + REPOSITORY: ${{needs.preflight.outputs.repository}} + hassfest: runs-on: ubuntu-latest name: Hassfest diff --git a/scripts/check/existing.py b/scripts/check/existing.py new file mode 100644 index 0000000..98b5f7b --- /dev/null +++ b/scripts/check/existing.py @@ -0,0 +1,34 @@ +import asyncio +import os +import requests + +CHECKURL = "https://data-v2.hacs.xyz/removed/repositories.json" + +CATEGORIES = [ + "appdaemon", + "integration", + "netdaemon", + "plugin", + "python_script", + "template", + "theme", +] + + +async def check(): + repo = os.environ["REPOSITORY"].lower() + + for category in CATEGORIES: + checkurl = f"https://data-v2.hacs.xyz/{category}/repositories.json" + try: + category_repositories = set(x.lower() for x in requests.get(checkurl).json()) + if repo in category_repositories: + exit(f"::error::'{repo}' alredy exist as a {category} in HACS") + except Exception as e: + exit(f"::error::{e}") + + print("Repository does not exist in HACS") + + +if __name__ == "__main__": + asyncio.get_event_loop().run_until_complete(check())