File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -125,8 +125,20 @@ function toStr(obj) {
125125 return JSON . stringify ( obj , null , 2 ) ;
126126}
127127
128+ function isRunningInGitHubActions ( ) {
129+ return process . env . GITHUB_ACTIONS === 'true' ;
130+ }
131+
128132const DOWNLOAD_HISTORY_URL = "https://public-stats.phcode.io/generated/download_history.json" ;
129133async function getCurrentHistoryData ( ) {
134+ if ( isRunningInGitHubActions ( ) ) {
135+ // in github actions, there can be times when fetch fails in the automated hourly
136+ // workflows. In that case we should fail early, else it will reset the history
137+ // if we do try catch and return null. We dont want automated workflows resetting
138+ // history.
139+ const fetchedData = await fetch ( DOWNLOAD_HISTORY_URL ) ;
140+ return fetchedData . json ( ) ;
141+ }
130142 try {
131143 const fetchedData = await fetch ( DOWNLOAD_HISTORY_URL ) ;
132144 return await fetchedData . json ( ) ;
You can’t perform that action at this time.
0 commit comments