Skip to content

Commit

Permalink
fix: accidental download history reset in github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Oct 20, 2024
1 parent 59bc90f commit aa3f722
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions build/downloadHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,20 @@ function toStr(obj) {
return JSON.stringify(obj, null, 2);
}

function isRunningInGitHubActions() {
return process.env.GITHUB_ACTIONS === 'true';
}

const DOWNLOAD_HISTORY_URL = "https://public-stats.phcode.io/generated/download_history.json";
async function getCurrentHistoryData() {
if(isRunningInGitHubActions()){
// in github actions, there can be times when fetch fails in the automated hourly
// workflows. In that case we should fail early, else it will reset the history
// if we do try catch and return null. We dont want automated workflows resetting
// history.
const fetchedData = await fetch(DOWNLOAD_HISTORY_URL);
return fetchedData.json();
}
try{
const fetchedData = await fetch(DOWNLOAD_HISTORY_URL);
return await fetchedData.json();
Expand Down

0 comments on commit aa3f722

Please sign in to comment.