Project Watch #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: Project Watch | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 7 * * 1" | |
| permissions: | |
| contents: write | |
| issues: write | |
| jobs: | |
| monitor: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Run project checks | |
| id: checks | |
| continue-on-error: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| python scripts/check_projects.py \ | |
| --registry projects.json \ | |
| --status-json monitoring/project-status.json \ | |
| --status-md monitoring/project-status.md | |
| - name: Detect snapshot changes | |
| id: snapshot | |
| shell: bash | |
| run: | | |
| if git diff --quiet -- monitoring/project-status.json monitoring/project-status.md; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Commit updated monitoring snapshot | |
| if: steps.snapshot.outputs.changed == 'true' | |
| shell: bash | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add monitoring/project-status.json monitoring/project-status.md | |
| git commit -m "chore: update project watch snapshot" | |
| git push | |
| - name: Open issue when alerts or changes are detected | |
| if: steps.checks.outcome != 'success' || steps.snapshot.outputs.changed == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require("fs"); | |
| const body = fs.readFileSync("monitoring/project-status.md", "utf8"); | |
| const title = `Project watch update - ${new Date().toISOString().slice(0, 10)}`; | |
| await github.rest.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title, | |
| body | |
| }); |