Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adiciona script para download do CSV insumos #167

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/get_insumos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: get_insumos

on:
schedule:
- cron: '0 12 * * *'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Get insumos
run: make docker-get-insumos
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ docker-deploy:

docker-validate: docker-build
docker container run --rm --name covid19-br --volume $(PWD)/data/output:/app/data/output covid19-br ./validate.sh

docker-get-insumos: docker-build
docker container run --env-file ./.env --rm --name covid19-br --volume $(PWD)/data:/app/data covid19-br ./get_insumos.sh
28 changes: 28 additions & 0 deletions get_insumos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -e
SCRIPT_PATH=$(dirname ${BASH_SOURCE[0]})
source $SCRIPT_PATH/base.sh

URL="https://covid-insumos.saude.gov.br/paineis/insumos/lista_csv_painel.php?output=csv"
DATETIME=$(date +%Y%m%d%H%M%S)

log "[insumos] Downloading last CSV for insumos ..."
wget -q -c -t 0 -O "$DOWNLOAD_PATH/insumos/insumos-${DATETIME}Z.csv" "$URL"

log "[insumos] Compressing last CSV for insumos ..."
gzip "$DOWNLOAD_PATH/insumos/insumos-${DATETIME}Z.csv"

#log "[insumos] Sending CSV to Brasil.IO ..."
#TODO - para que isso funcione via GitHub Actions será necessário ter o HOST que brasil.io
# usa para o object storage S3, e definir as variáveis na configuração do GITHUB
# s3cmd \
# --access_key="$S3_ACCESS_KEY" \
# --secret_key="$S3_SECRET_KEY" \
# --host="$S3_HOSTNAME" \
# --host-bucket="$S3_HOST_BUCKET" \
# put \
# "$DOWNLOAD_PATH/insumos/insumos-${DATETIME}Z.csv.gz" \
# s3://dataset/$DATASET/insumos/insumos-${DATETIME}Z.csv.gz

log "[insumos] Done"