Update check PR workflow

This commit is contained in:
Ivanq 2021-03-25 16:39:57 +03:00
parent 50c172af5d
commit c6fa0412e4
2 changed files with 21 additions and 4 deletions

View file

@ -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

View file

@ -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)