Scrape daily data #1384
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
# This is a basic workflow to help you get started with Actions | |
name: Scrape daily data | |
# Controls when the action will run. | |
on: | |
schedule: | |
- cron: '1 0 * * *' | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
scheduled: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out this repo | |
uses: actions/checkout@v2 | |
- name: Fetch latest data | |
run: |- | |
curl "https://apidatos.ree.es/datos/mercados/precios-mercados-tiempo-real?start_date=`date --iso-8601`T00:00&end_date=`date --iso-8601`T23:59&time_trunc=hour" | tee data.json | |
- name: Commit and push if it changed | |
run: |- | |
git config user.name "Automated" | |
git config user.email "actions@users.noreply.github.com" | |
git add -A | |
timestamp=$(date -u) | |
git commit -m "Latest data: ${timestamp}" || exit 0 | |
git push |