name: Freshness Check on: schedule: - cron: '0 8 * * 1' # Weekly, Monday 08:00 UTC workflow_dispatch: jobs: check: runs-on: ubuntu-latest permissions: issues: write steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '22' cache: 'npm' - run: npm ci - name: Check freshness id: freshness run: | npm run freshness:check echo "stale=$(cat .freshness-stale)" >> $GITHUB_OUTPUT - name: Create issue if stale if: steps.freshness.outputs.stale == 'true' uses: actions/github-script@v7 with: script: | const fs = require('fs'); const summary = fs.readFileSync('.freshness-report', 'utf8'); const existing = await github.rest.issues.listForRepo({ owner: context.repo.owner, repo: context.repo.repo, labels: 'data-freshness', state: 'open' }); if (existing.data.length === 0) { await github.rest.issues.create({ owner: context.repo.owner, repo: context.repo.repo, title: `Data staleness alert - ${new Date().toISOString().split('T')[0]}`, body: summary, labels: ['data-freshness', 'automated'] }); }