Skip to content

Commit

Permalink
Skip generation of latest.json if there's no data
Browse files Browse the repository at this point in the history
Fixing a bug that will overwrite the file if there's missing data.
  • Loading branch information
benlower committed Apr 26, 2024
1 parent f9522fb commit eef92f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ jobs:
- name: Get data and update file
run: |
OUTPUT="$(node ./utils/GenerateLatestData.js)"
echo "$OUTPUT" > ./website/public/data/latest.json
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add ./website/public/data/latest.json
git commit -m "Update latest data"
git push
if [ -n "$OUTPUT" ]; then
echo "$OUTPUT" > ./website/public/data/latest.json
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add ./website/public/data/latest.json
git commit -m "Update latest data"
git push
else
echo "No data generated, skipping Git operations."
fi
build-and-deploy-site:
needs: generate-latest-data
Expand Down
4 changes: 2 additions & 2 deletions utils/GenerateLatestData.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ async function fetchAndMergeFiles(date) {

// If no files were found, do not update "latest.json"
if (validResults.length === 0) {
console.log('No files found for the given date. "latest.json" will not be updated.');
return;
}

Expand All @@ -40,5 +39,6 @@ async function fetchAndMergeFiles(date) {
}

// Example usage with the current date
const currentDate = new Date().toISOString().split('T')[0]; // Format: YYYY-MM-DD
// const currentDate = new Date().toISOString().split('T')[0]; // Format: YYYY-MM-DD
const currentDate = '2024-03-01';

This comment has been minimized.

Copy link
@juberti

juberti Apr 26, 2024

Contributor

did you mean to commit this?

fetchAndMergeFiles(currentDate);

0 comments on commit eef92f2

Please sign in to comment.