-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (52 loc) · 2.13 KB
/
Copy pathdaily.yml
File metadata and controls
61 lines (52 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# 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 }}