From 670a4232faba1bd73402cb07514d890ea364913f Mon Sep 17 00:00:00 2001 From: Caesar Wong <112133161+caesarw0@users.noreply.github.com> Date: Sat, 9 Sep 2023 11:39:56 -0700 Subject: [PATCH] Create update_csv.yml --- .github/workflows/update_csv.yml | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/update_csv.yml diff --git a/.github/workflows/update_csv.yml b/.github/workflows/update_csv.yml new file mode 100644 index 0000000..c17b207 --- /dev/null +++ b/.github/workflows/update_csv.yml @@ -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