Repository navigation
Production Smoke #1267
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: Production Smoke | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| force_failure: | |
| description: "Force a smoke failure to test failure notifications" | |
| required: false | |
| type: boolean | |
| default: false | |
| schedule: | |
| - cron: "*/30 * * * *" | |
| workflow_run: | |
| workflows: | |
| - Deploy Web to Cloudflare Pages | |
| types: | |
| - completed | |
| permissions: | |
| contents: read | |
| issues: write | |
| jobs: | |
| smoke: | |
| if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' | |
| runs-on: ubuntu-latest | |
| env: | |
| MOSHI_WEBHOOK_TOKEN: ${{ secrets.MOSHI_WEBHOOK_TOKEN }} | |
| GROUND_CODES_SMOKE_FORCE_FAILURE: ${{ github.event.inputs.force_failure || 'false' }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "22" | |
| package-manager-cache: false | |
| - name: Run production smoke | |
| run: node scripts/production-smoke.mjs | |
| - name: Notify smoke failure | |
| if: failure() && env.MOSHI_WEBHOOK_TOKEN != '' | |
| run: | | |
| curl -X POST https://api.getmoshi.app/api/webhook \ | |
| -H "Content-Type: application/json" \ | |
| -d "{\"token\":\"${MOSHI_WEBHOOK_TOKEN}\",\"title\":\"ground.codes smoke failed\",\"message\":\"Production smoke failed on ${GITHUB_REF_NAME}. Run: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\"}" | |
| - name: Open smoke failure issue | |
| if: failure() && env.MOSHI_WEBHOOK_TOKEN == '' | |
| uses: actions/github-script@v8 | |
| with: | |
| script: | | |
| const title = "Production smoke failed"; | |
| const runUrl = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}`; | |
| const message = [ | |
| `Production smoke failed on ${process.env.GITHUB_REF_NAME}.`, | |
| "", | |
| `Run: ${runUrl}`, | |
| "", | |
| "MOSHI_WEBHOOK_TOKEN is not configured, so this issue is the fallback notification.", | |
| ].join("\n"); | |
| const { owner, repo } = context.repo; | |
| const { data: issues } = await github.rest.issues.listForRepo({ | |
| owner, | |
| repo, | |
| state: "open", | |
| per_page: 50, | |
| }); | |
| const existing = issues.find((issue) => issue.title === title); | |
| if (existing) { | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number: existing.number, | |
| body: message, | |
| }); | |
| } else { | |
| await github.rest.issues.create({ | |
| owner, | |
| repo, | |
| title, | |
| body: message, | |
| }); | |
| } |