generated from jacobtomlinson/python-container-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
29 lines (24 loc) · 813 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import sys
import re
def main():
expression = os.environ["INPUT_EXPRESSION"]
strings = os.environ["INPUT_STRINGS"]
groups = None
match = None
for i in strings.split(" "):
match = re.match(expression, i)
if match:
if groups is None:
groups = match.groups()
elif groups != match.groups():
sys.exit("Groups dont match" +
"\nGroup 1: " + str(groups) +
"\nGroup 2: " + str(match.groups()))
else:
sys.exit("String doesnt match the pattern" +
"\nString: " + i)
print(f"::set-output name=groups::{' '.join(match.groups())}")
print(f"::set-output name=result::{match.group(0)}")
if __name__ == "__main__":
main()