|
| 1 | +name: Monitor Demo Site |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: '0 * * * *' |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + paths: |
| 11 | + - demo/** |
| 12 | + - render.yaml |
| 13 | + - scripts/check-demo-site.sh |
| 14 | + - .github/workflows/monitor-demo.yml |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + issues: write |
| 19 | + |
| 20 | +jobs: |
| 21 | + smoke-check: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Wait for deploy propagation |
| 29 | + if: github.event_name == 'push' |
| 30 | + run: sleep 240 |
| 31 | + |
| 32 | + - name: Run production smoke check |
| 33 | + run: bash scripts/check-demo-site.sh |
| 34 | + |
| 35 | + - name: Create or update incident issue |
| 36 | + if: failure() |
| 37 | + uses: actions/github-script@v7 |
| 38 | + with: |
| 39 | + script: | |
| 40 | + const title = 'Demo site smoke check failing'; |
| 41 | + const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; |
| 42 | + const body = [ |
| 43 | + 'Automated smoke check failed.', |
| 44 | + '', |
| 45 | + `- Workflow run: ${runUrl}`, |
| 46 | + `- Event: ${context.eventName}`, |
| 47 | + `- SHA: ${context.sha}`, |
| 48 | + `- UTC: ${new Date().toISOString()}`, |
| 49 | + '', |
| 50 | + 'Please inspect the Render deploy status and logs.' |
| 51 | + ].join('\n'); |
| 52 | +
|
| 53 | + const { data: issues } = await github.rest.issues.listForRepo({ |
| 54 | + owner: context.repo.owner, |
| 55 | + repo: context.repo.repo, |
| 56 | + state: 'open', |
| 57 | + per_page: 100, |
| 58 | + }); |
| 59 | +
|
| 60 | + const existing = issues.find((issue) => issue.title === title); |
| 61 | + if (existing) { |
| 62 | + await github.rest.issues.createComment({ |
| 63 | + owner: context.repo.owner, |
| 64 | + repo: context.repo.repo, |
| 65 | + issue_number: existing.number, |
| 66 | + body, |
| 67 | + }); |
| 68 | + return; |
| 69 | + } |
| 70 | +
|
| 71 | + await github.rest.issues.create({ |
| 72 | + owner: context.repo.owner, |
| 73 | + repo: context.repo.repo, |
| 74 | + title, |
| 75 | + body, |
| 76 | + }); |
0 commit comments