Skip to content

Commit aa3f722

Browse files
committed
fix: accidental download history reset in github actions
1 parent 59bc90f commit aa3f722

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

build/downloadHistory.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
128132
const DOWNLOAD_HISTORY_URL = "https://public-stats.phcode.io/generated/download_history.json";
129133
async 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();

0 commit comments

Comments
 (0)