Skip to content

Commit

Permalink
Update check PR workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
purplesyringa committed Mar 25, 2021
1 parent 50c172a commit c6fa041
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions check-signatures-format.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit c6fa041

Please sign in to comment.