Skip to content

Update Area Feeds (AI/Robotics/Quantum/Biotech/Nanotech) #258

Update Area Feeds (AI/Robotics/Quantum/Biotech/Nanotech)

Update Area Feeds (AI/Robotics/Quantum/Biotech/Nanotech) #258

name: Update Area Feeds (AI/Robotics/Quantum/Biotech/Nanotech)
on:
workflow_dispatch: {}
# Run four times per day.
schedule:
- cron: "17 */6 * * *"
# Rebuild when the registry, builder, validators, or workflow changes.
push:
branches:
- main
paths:
- "feeds.yaml"
- "scripts/**"
- ".github/workflows/update-area-feeds.yml"
# Every workflow that commits generated feed files shares one lock.
concurrency:
group: feed-writers-main
cancel-in-progress: false
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 330
steps:
- name: Checkout full repository history
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
- name: Configure Git
shell: bash
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: scripts/requirements.txt
- name: Install dependencies
shell: bash
run: |
set -euo pipefail
python -m pip install --upgrade pip
pip install -r scripts/requirements.txt
- name: Validate feed registry
shell: bash
run: |
set -euo pipefail
python scripts/validate_feeds_config.py
- name: Build all area feeds
shell: bash
run: |
set -euo pipefail
python scripts/update_feeds.py
- name: Validate generated outputs
shell: bash
run: |
set -euo pipefail
python scripts/validate_generated_feeds.py
- name: Gzip generated feeds
shell: bash
run: |
set -euo pipefail
shopt -s nullglob
for file in feeds/*.xml feeds/*.json; do
gzip -kf "$file"
done
- name: Commit generated files
shell: bash
run: |
set -euo pipefail
git add -A
if git diff --cached --quiet; then
echo "No generated feed changes to commit."
exit 0
fi
git commit -m "chore: update feeds & index [skip ci]"
branch="${GITHUB_REF_NAME:-main}"
for attempt in 1 2 3; do
echo "Synchronize and push attempt ${attempt} of 3"
git fetch origin "$branch"
if ! git rebase "origin/$branch"; then
echo "Rebase conflict detected; stopping instead of reporting false success."
git rebase --abort || true
exit 1
fi
if git push origin "HEAD:$branch"; then
echo "Generated feeds pushed successfully."
exit 0
fi
if [ "$attempt" -lt 3 ]; then
echo "Remote changed before push; waiting before retry."
sleep 10
fi
done
echo "Push failed after three attempts."
exit 1
- name: Lightweight repository cleanup
if: always()
shell: bash
run: git gc --prune=now || true