From 3b1e9c241a07270536a0ffee95570c5e752f8016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Sat, 13 Mar 2021 15:00:23 +0100 Subject: [PATCH] Add edits check (#862) --- .github/workflows/checks.yml | 14 ++++++++++++++ scripts/check/edits.py | 15 +++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 scripts/check/edits.py diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 8bc6d15..7634fc5 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -71,6 +71,20 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + edits: + runs-on: ubuntu-latest + name: Check if PR is editable + steps: + - name: Check out repository + uses: actions/checkout@v2 + + - name: Install dependencies if needed + run: make init + + - name: Run the check + run: python3 -m scripts.check.edits + + hassfest: runs-on: ubuntu-latest name: "Check hassfest" diff --git a/scripts/check/edits.py b/scripts/check/edits.py new file mode 100644 index 0000000..0a8210f --- /dev/null +++ b/scripts/check/edits.py @@ -0,0 +1,15 @@ +import asyncio + +from scripts.helpers.event import get_event + + +async def check(): + event = get_event() + pull_request = event["pull_request"] + if not pull_request["maintainer_can_modify"]: + if pull_request["head"]["repo"]["full_name"] != "hacs/default": + exit("::error::The PR is not editable by HACS maintainers") + + +if __name__ == "__main__": + asyncio.get_event_loop().run_until_complete(check())