diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml index 78e670b26d..9a508147db 100644 --- a/.github/workflows/check-pr.yml +++ b/.github/workflows/check-pr.yml @@ -1,13 +1,14 @@ -name: Do not modify index.md directly, add a file to _data/signed instead +name: Check signatures format on: pull_request: branches: - master paths: - - index.md + - _data/signed/* jobs: deploy: runs-on: ubuntu-latest steps: - - name: Throw error - run: echo "Do not modify index.md directly, add a file to _data/signed instead"; exit 1 + - uses: actions/checkout@v2 + - name: Check signatures format + run: python3 check-signatures-format.py diff --git a/check-signatures-format.py b/check-signatures-format.py new file mode 100644 index 0000000000..046b79ffdb --- /dev/null +++ b/check-signatures-format.py @@ -0,0 +1,16 @@ +import os +import re + + +regex = re.compile(r"name: (\S+\s)*\S+\nlink: (/#|(https?://|mailto:)[a-zA-Z0-9_().@:%\+~#?&//=-]+)\n{,2}") + +ok = True +for file_name in sorted(os.listdir("_data/signed")): + with open(f"_data/signed/{file_name}") as f: + contents = f.read() + if not re.fullmatch(regex, contents): + print(file_name, "has invalid format") + ok = False + +if not ok: + raise SystemExit(1)