Registry freshness #1
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: Registry freshness | |
| on: | |
| schedule: [{cron: "0 7 * * 1"}] # chaque lundi | |
| workflow_dispatch: | |
| permissions: {} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| check: | |
| # read: checkout ; issues: open the registry-refresh reminder | |
| permissions: {contents: read, issues: write} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: {persist-credentials: false} | |
| - id: age | |
| run: | | |
| python - <<'PY' >> $GITHUB_OUTPUT | |
| import json, datetime | |
| m = json.load(open("references/model_registry.json"))["_meta"] | |
| d = (datetime.date.today() - datetime.date.fromisoformat(m["verified_at"])).days | |
| print(f"days={d}") | |
| print(f"stale={'true' if d > 30 else 'false'}") | |
| PY | |
| - if: steps.age.outputs.stale == 'true' | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| env: | |
| # passé par l'environnement, jamais interpolé dans le script : | |
| # une expression ${{ }} rendue dans du code exécutable est le vecteur | |
| # d'injection classique des workflows. | |
| REGISTRY_AGE_DAYS: ${{ steps.age.outputs.days }} | |
| with: | |
| script: | | |
| const days = process.env.REGISTRY_AGE_DAYS; | |
| const title = `Refresh model price registry (${days} days old)`; | |
| const {data: open} = await github.rest.issues.listForRepo({ | |
| ...context.repo, state: "open", labels: "registry"}); | |
| if (open.some(i => i.title.startsWith("Refresh model price registry"))) return; | |
| await github.rest.issues.create({...context.repo, title, labels: ["registry"], | |
| body: [ | |
| `The 30-day price check is overdue: \`_meta.verified_at\` is ${days} days old.`, | |
| "", | |
| "Check the official pages listed in `_meta.sources`, update the", | |
| "models you use, bump `verified_at`. Takes about ten minutes and", | |
| "keeps every FinOps dashboard honest.", | |
| ].join("\n")}); |