File tree Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 34
34
GH_TOKEN : ${{ secrets.RERUN_BOT_TOKEN }}
35
35
run : |
36
36
commit_message=$(git log --pretty=format:%s -n 1 ${{ github.sha }})
37
- pr_number=$(echo $commit_message | grep -oP '(?<=#)\d+' )
37
+ pr_number=$(python3 scripts/ci/parse_pr_number.py " $commit_message" )
38
38
39
39
result=$(gh pr view $pr_number --json labels | jq -r 'any(.labels[].name; . == "deploy docs")')
40
40
echo "result=$result" >> $GITHUB_OUTPUT
Original file line number Diff line number Diff line change 1
1
rerun_cpp /docs /** /*
2
2
3
3
rerun_py /docs /templates /**
4
+ rerun_py /site /**
4
5
5
6
rerun_js /web-viewer /re_viewer_bg.js
6
7
rerun_js /web-viewer /re_viewer.js
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import sys
7
+
8
+
9
+ def parse_pr_number (commit_message : str ) -> int :
10
+ first_line = commit_message .splitlines ()[0 ]
11
+ start_idx = first_line .rfind ("(#" )
12
+ if start_idx == - 1 :
13
+ raise Exception ("failed to parse PR number: no PR number in commit message, expected to find '(#1234)'" )
14
+ start_idx += 2 # trim '(#'
15
+
16
+ end_idx = first_line .find (")" , start_idx )
17
+ if end_idx == - 1 :
18
+ raise Exception ("failed to parse PR number: unclosed parenthesis, expected to find '(#1234)'" )
19
+ # end idx is exclusive, no need to trim
20
+
21
+ digits = first_line [start_idx :end_idx ]
22
+ return int (digits )
23
+
24
+
25
+ def main () -> None :
26
+ parser = argparse .ArgumentParser ()
27
+ parser .add_argument ("commit_message" , type = str )
28
+
29
+ args , unknown = parser .parse_known_args ()
30
+ for arg in unknown :
31
+ print (f"Unknown argument: { arg } " )
32
+
33
+ pr_number = parse_pr_number (args .commit_message )
34
+ sys .stdout .write (str (pr_number ))
35
+ sys .stdout .flush ()
36
+
37
+
38
+ if __name__ == "__main__" :
39
+ main ()
You can’t perform that action at this time.
0 commit comments