File tree Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Expand file tree Collapse file tree 2 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 1111 build :
1212 runs-on : ubuntu-latest
1313 steps :
14+ - name : Checkout
15+ uses : actions/checkout@v2
1416 - name : Check URLs
1517 uses : paramt/url-checker@master
1618 with :
2325
2426# ## Sample Output
2527[](https://github.com/paramt/url-checker/commit/093ef6cb5f7e9eff8300887f07eb0c3a55f4aa82/checks)
26-
27- > Note: url-checker only works on public repositories
Original file line number Diff line number Diff line change 1616def remove_duplicates (urls ):
1717 return list (set (urls ))
1818
19+
20+ def get_test_from_file (file ):
21+ # Assume the local file has been checked out in the action
22+ try :
23+ with open ('./' + file ) as f :
24+ text = f .readlines ()
25+ except FileNotFoundError as e :
26+ print ("Could not find file checked out locally, falling back to using public link" )
27+
28+ # Fall-back to pulling from the public URL for backawards comaptibility
29+ try :
30+ filepath = "https://raw.githubusercontent.com/" + repo + "/master/" + file
31+ r = requests .get (filepath )
32+ r .raise_for_status ()
33+ return r .text
34+ except requests .exceptions .HTTPError as err :
35+ print ("Could not find file using fallback public link" )
36+
37+
1938for file in files :
20- print (f"Collecting URLs from { file } " )
21- filepath = "https://raw.githubusercontent.com/" + repo + "/master/" + file
22- text = requests .get (filepath ).text
39+
40+ text = get_test_from_file (file )
2341
2442 extractor = URLExtract ()
2543 file_links = extractor .find_urls (text )
You can’t perform that action at this time.
0 commit comments