Skip to content

Scrape data

Scrape data #13556

Workflow file for this run

name: Scrape data
on:
push:
workflow_dispatch:
schedule:
- cron: '9 * * * *' #1700 SGT
jobs:
scheduled:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- name: Check out this repo
uses: actions/checkout@v2
- name: Fetch latest data
run: |-
today=$(date +"%Y-%m-%d")
curl -X GET "https://api.data.gov.sg/v1/environment/air-temperature?date=$today" -H "accept: application/json" | jq . > weather.json
- name: Commit and push if it changed
run: |-
git config user.name "Github Actions"
git config user.email "[email protected]"
git add -A
timestamp=$(date -u)
git commit -m "Latest data: ${timestamp}" || exit 0
git push