Update update_csv.yml - adding "git add" #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Daily CSV Update | |
on: push | |
#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/9a9f14e1-03ea-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/childcare_locations.csv | |
# Replace 'data/childcare_locations.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 add data/childcare_locations.csv | |
git commit -am "Update CSV file" | |
git push |