Skip to content

Update raw data

Update raw data #95

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: Update raw data
# Controls when the workflow will run
on:
schedule:
- cron: '0 0 * * *' # Runs every day at midnight UTC
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
main:
runs-on: ubuntu-latest
permissions:
contents: write # 'write' access to repository contents
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: IBGE States > Download states raw data
run: |
mkdir -p raw/localities/bra/ibge
curl -s https://servicodados.ibge.gov.br/api/v1/localidades/estados -o raw/localities/bra/ibge/states.json
- name: IBGE Cities > Download and merge cities raw data for each state
run: |
SIGLAS=$(jq -r '.[].sigla' raw/localities/bra/ibge/states.json | sort)
echo "" > raw/localities/bra/ibge/cities.json
for UF in $SIGLAS; do
echo $(curl -s "https://servicodados.ibge.gov.br/api/v1/localidades/estados/${UF}/municipios") >> raw/localities/bra/ibge/cities.json
done
DATA=$(cat raw/localities/bra/ibge/cities.json | jq -c -s 'flatten(1) | sort_by(.id)' | sort)
echo "$DATA" > raw/localities/bra/ibge/cities.json
- name: PGE_SIAFI > Download the raw file
run: |
mkdir -p raw/localities/bra/siafi
curl -L -o raw/localities/bra/siafi/pge_siafi.xls https://thot-arquivos.tesouro.gov.br/publicacao/28259
- name: PGE_SIAFI > Convert Excel to JSON
run: |
pip install pandas
pip install xlrd
python convert_siafi_to_json.py
- name: Commit changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .
if ! git diff --cached --quiet; then
git commit -m 'Merge of new localities'
else
echo "No changes to commit."
fi
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}