Run Scraper Monthly #1
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: Run Scraper Monthly | |
on: | |
schedule: | |
- cron: "0 3 1 * *" | |
jobs: | |
run-scraper: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
working-directory: ./backend | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Calcula o mês anterior e respectivo ano | |
id: calc-date | |
run: | | |
LAST_MONTH=$(date --date="$(date +%Y-%m-15) -1 month" +%m) | |
LAST_YEAR=$(date --date="$(date +%Y-%m-15) -1 month" +%Y) | |
echo "LAST_MONTH=$LAST_MONTH" >> $GITHUB_ENV | |
echo "LAST_YEAR=$LAST_YEAR" >> $GITHUB_ENV | |
- name: Executa o raspador | |
working-directory: ./backend/raspadores/Selenium_transparencia | |
run: | | |
python3 portal_transparência_busca_específica.py --ano ${{ env.LAST_YEAR }} --mes ${{ env.LAST_MONTH }} | |
- name: Cria arquivo .env | |
working-directory: ./backend | |
run: | | |
echo SUPABASE_URL=${{ secrets.SUPABASE_URL }} >> .env | |
echo SUPABASE_KEY=${{ secrets.SUPABASE_KEY }} >> .env | |
- name: Instalando Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20.12.2' | |
- name: Instalando Node.js dependencias | |
working-directory: ./backend/ | |
run: | | |
npm install | |
- name: Executa insertTendersMonth.js | |
working-directory: ./backend/src/scripts | |
run: | | |
node insertTendersMonth.js | |
- name: Executa insertTendersYear.js | |
working-directory: ./backend/src/scripts | |
run: | | |
node insertTendersYear.js | |
- name: Deleta json gerado pelo raspador | |
working-directory: ./backend/raspadores/Selenium_transparencia | |
run: | | |
rm selenium_portal_transparencia_.json |