Download Source; Build the Feed #482
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: "Download Source; Build the Feed" | |
on: | |
push: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 2,14 * * *' # every day at noon UTC plus two hours, since COTA publishes their stuff around 9 a.m. Eastern. Also at 10 p.m. Eastern to catch evening updates before the morning commute. | |
permissions: | |
contents: write | |
jobs: | |
Download-and-Make: | |
runs-on: ubuntu-latest | |
steps: | |
- run: echo "ℹ️ The job was automatically triggered by a ${{ github.event_name }} event." | |
- name: Check out this repo | |
uses: actions/checkout@v4 | |
- run: echo "ℹ️ The ${{ github.repository }} repository has been cloned to the runner." | |
- run: mkdir -p build/ | |
- name: Fetch latest data from the API endpoint | |
run: |- | |
bash ./scraper.bash | |
- name: "Save files" | |
uses: actions/upload-artifact@v3 | |
with: | |
name: acf-options.json | |
path: build/acf-options.json | |
- name: Parse scrape and update JSON | |
run: |- | |
php ./parser.php | |
- name: Generate RSS feed | |
run: |- | |
php ./rss.php > rss.xml | |
- name: "Save files" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: acf-options.json | |
path: build/acf-options.json | |
if-no-files-found: error | |
- name: "🛑 Preserve php errors" | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: php-error.log | |
path: | | |
./php-error.log | |
./alerts-log.csv | |
./build/* | |
- name: "▶️ Commit and push if the data has changed" | |
run: |- | |
git config user.name "Automated" | |
git config user.email "actions@users.noreply.github.com" | |
git add -A | |
timestamp=$(date -u) | |
git commit -m "Latest data: ${timestamp}" || exit 0 | |
git pull --rebase | |
git push | |