Generate README Cards (No External Services) #90
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: Generate README Cards (No External Services) | |
| on: | |
| schedule: | |
| - cron: "17 2 * * *" # daily 02:17 UTC | |
| workflow_dispatch: | |
| concurrency: | |
| group: readme-cards-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-cards: | |
| name: 🧩 Generate README Cards | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: 📦 Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: 🐍 Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: ✅ Validate generator script exists | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| if [[ ! -f ".github/scripts/generate_readme_cards.py" ]]; then | |
| echo "::error file=.github/scripts/generate_readme_cards.py::Generator script not found." | |
| exit 1 | |
| fi | |
| - name: 🧠 Generate SVG cards | |
| shell: bash | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GITHUB_USERNAME: ${{ github.repository_owner }} | |
| run: | | |
| set -euo pipefail | |
| python -V | |
| python .github/scripts/generate_readme_cards.py | |
| - name: 🧾 Commit & push if changed (safe rebase) | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| # Guard: avoid scheduled runs pushing to non-default branches | |
| if [[ "${{ github.event_name }}" == "schedule" ]]; then | |
| default_branch="${{ github.event.repository.default_branch }}" | |
| if [[ "${GITHUB_REF_NAME}" != "${default_branch}" ]]; then | |
| echo "Scheduled run on '${GITHUB_REF_NAME}', but default branch is '${default_branch}'. Skipping push." | |
| echo "ℹ️ Scheduled run skipped (not default branch)." >> "$GITHUB_STEP_SUMMARY" | |
| exit 0 | |
| fi | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "No changes to commit." | |
| echo "✅ No README card changes detected." >> "$GITHUB_STEP_SUMMARY" | |
| exit 0 | |
| fi | |
| git commit -m "chore: update README cards" | |
| # Avoid non-fast-forward failures | |
| git pull --rebase origin "${GITHUB_REF_NAME}" | |
| git push origin "HEAD:${GITHUB_REF_NAME}" | |
| echo "✅ README cards updated and pushed to '${GITHUB_REF_NAME}'." >> "$GITHUB_STEP_SUMMARY" |