Skip to content

Commit

Permalink
Create update_csv.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
caesarw0 authored Sep 9, 2023
1 parent b7a9837 commit 670a423
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/update_csv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Daily CSV Update

on:
schedule:
- cron: '0 0 * * *' # Runs every day at midnight (UTC)

jobs:
update-csv:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Download New CSV
run: |
if curl -o data/new-data.csv https://catalogue.data.gov.bc.ca/dataset/4cc207cc-ff03-44f8-8c5f-415af5224646/resource/9a[…]-4a11-936a-6e77b15eeb39/download/childcare_locations.csv; then
echo "CSV download successful."
else
echo "CSV download failed."
exit 1
fi
- name: Check CSV File Size
id: check-csv
run: |
if [ -s data/new-data.csv ]; then
echo "CSV file is not empty."
else
echo "CSV file is empty."
exit 1
fi
- name: Overwrite CSV
if: steps.check-csv.outcome == 'success'
run: |
mv data/new-data.csv data/data.csv
# Replace 'data/data.csv' with the correct path and filename of your CSV file.

- name: Commit and Push Changes
if: steps.check-csv.outcome == 'success'
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git commit -am "Update CSV file"
git push

0 comments on commit 670a423

Please sign in to comment.