Download Feeds #313
This file contains hidden or 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: Download Feeds | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| fetch: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download all feeds | |
| run: | | |
| set -e | |
| YEAR=$(date '+%Y') | |
| DATETIME_FOLDER=$(date '+%d%m%Y%H%M') | |
| BASE_DIR="feed_arquivos" | |
| YEAR_DIR="$BASE_DIR/$YEAR" | |
| OUTPUT_DIR="$YEAR_DIR/$DATETIME_FOLDER" | |
| mkdir -p "$OUTPUT_DIR" | |
| echo "Criado: $OUTPUT_DIR" | |
| cat feed_list.yaml || (echo "Arquivo feed_list.yaml não encontrado" && exit 1) | |
| while read -r url; do | |
| file_timestamp=$(date '+%H%M%S') | |
| sanitized=$(echo "$url" | sed 's/[^A-Za-z0-9]/_/g' | cut -c1-50) | |
| output_file="$OUTPUT_DIR/${sanitized}-${file_timestamp}.xml" | |
| curl -L --fail --silent "$url" -o "$output_file" && echo "Download OK: $url" || echo "Falha no download: $url" | |
| done < <(grep -Eo 'https?://[^ ]+' feed_list.yaml) | |
| touch "$OUTPUT_DIR/.gitkeep" | |
| echo "Conteúdo criado:" | |
| find "$BASE_DIR" | |
| - name: Commit changes | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A feed_arquivos | |
| git status | |
| git commit -m "chore: update RSS feeds" || echo "Nada para comitar." | |
| git push || echo "Nada para enviar." | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |