File tree Expand file tree Collapse file tree 3 files changed +17
-10
lines changed
Expand file tree Collapse file tree 3 files changed +17
-10
lines changed Original file line number Diff line number Diff line change 1818 - uses : actions/checkout@v2
1919
2020 - name : Check content
21- 21+ 2222 with :
2323 expression : ^contributions/(.+)/(.+)/
2424 strings : contributions/1/2/ contributions/1/2/
4242| Output | Description |
4343| ------------------------------------------------------| -----------------------------------------------|
4444| ` groups ` | The matching groups (based on regex) |
45+ | ` result ` | Result of the matching |
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ inputs:
1111outputs :
1212 groups :
1313 description : " The matching groups (based on regex)"
14+ result :
15+ description : " Result of the matching"
1416runs :
1517 using : " docker"
1618 image : " Dockerfile"
Original file line number Diff line number Diff line change 22import sys
33import re
44
5+
56def main ():
67 expression = os .environ ["INPUT_EXPRESSION" ]
78 strings = os .environ ["INPUT_STRINGS" ]
8-
9+
910 groups = None
11+ match = None
1012 for i in strings .split (" " ):
11- m = re .match (expression , i )
12- if m :
13+ match = re .match (expression , i )
14+ if match :
1315 if groups is None :
14- groups = m .groups
15- elif groups != m .groups :
16+ groups = match .groups ()
17+ elif groups != match .groups () :
1618 sys .exit ("Groups dont match" +
17- "\n Group 1: " + str (groups () ) +
18- "\n Group 2: " + str (m .groups ()))
19+ "\n Group 1: " + str (groups ) +
20+ "\n Group 2: " + str (match .groups ()))
1921 else :
2022 sys .exit ("String doesnt match the pattern" +
2123 "\n String: " + i )
22- print (f"::set-output name=groups::{ groups } " )
23-
24+ print (f"::set-output name=groups::{ match .groups ()} " )
25+ print (f"::set-output name=result::{ match .group (0 )} " )
26+
27+
2428if __name__ == "__main__" :
2529 main ()
You can’t perform that action at this time.
0 commit comments