.github/workflows/usa_scheduled.yml #11680
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: Fetch latest USA data | |
on: | |
repository_dispatch: | |
schedule: | |
- cron: '30 4 * * *' | |
jobs: | |
scheduled: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out this repo | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v1 | |
with: | |
python-version: 3.8 | |
- uses: actions/cache@v1 | |
name: Configure pip caching | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install Python dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Fetch latest USA data | |
run: |- | |
mkdir -p tmp_usa && cd tmp_usa | |
conditional-get --etags ../etags.json -v https://covidtracking.com/api/v1/states/current.json | |
(test -f current.json && jq . current.json > ../usa/current.json) || echo "No update for data_latest.json, skipping." | |
conditional-get --etags ../etags.json -v https://covidtracking.com/api/v1/states/daily.json | |
(test -f daily.json && jq . daily.json > ../usa/daily_state.json) || echo "No update for daily.json, skipping." | |
conditional-get --etags ../etags.json -v https://covidtracking.com/api/v1/states/info.json | |
(test -f info.json && jq . info.json > ../usa/info.geojson) || echo "No update for info.json, skipping." | |
conditional-get --etags ../etags.json -v https://covidtracking.com/api/v1/us/current.json | |
(test -f current.json && jq . current.json > ../usa/current.json) || echo "No update for current.json, skipping." | |
conditional-get --etags ../etags.json -v https://covidtracking.com/api/v1/us/daily.json | |
(test -f daily.json && jq . daily.json > ../usa/daily_us.json) || echo "No update for daily.json, skipping." | |
conditional-get --etags ../etags.json -v https://covidtracking.com/api/v1/urls.json | |
(test -f urls.json && jq . urls.json > ../usa/urls.json) || echo "No update for urls.json, skipping." | |
cd .. && rm -rf tmp_usa | |
- name: Commit and push USA data 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 USA data: ${timestamp}" || exit 0 | |
git push |