From 159e81688b5102b18a48cf0f3c6b6faa4a472ba5 Mon Sep 17 00:00:00 2001 From: Promise Raji Date: Thu, 23 Jul 2026 08:32:31 +0100 Subject: [PATCH 1/2] Closes: #17 Render Deployment Health Check Worflow --- .github/workflows/health-check.yml | 55 ++++++++++++++++++++++++++++++ README.md | 2 ++ context/progress-tracker.md | 5 +++ 3 files changed, 62 insertions(+) create mode 100644 .github/workflows/health-check.yml diff --git a/.github/workflows/health-check.yml b/.github/workflows/health-check.yml new file mode 100644 index 0000000..8bc829f --- /dev/null +++ b/.github/workflows/health-check.yml @@ -0,0 +1,55 @@ +name: Health Check + +on: + schedule: + - cron: '0 */6 * * *' + workflow_dispatch: + +jobs: + ping-health: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Ping Health Endpoint + id: ping + run: | + status=$(curl -sf -o /dev/null -w "%{http_code}" https://stepfi-api.onrender.com/api/v1/health || echo "failed") + echo "status=$status" >> "$GITHUB_OUTPUT" + + - name: Handle Failure + if: steps.ping.outputs.status != '200' + uses: actions/github-script@v7 + with: + script: | + const status = '${{ steps.ping.outputs.status }}'; + const timestamp = new Date().toISOString(); + const issueTitle = `Health check failed at ${timestamp}`; + const issueBody = `The health check endpoint returned HTTP status ${status}.`; + const label = 'incident'; + + const { data: issues } = await github.rest.issues.listForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + labels: label + }); + + if (issues.length > 0) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issues[0].number, + body: `Health check failed again at ${timestamp} with HTTP status ${status}.` + }); + console.log(`Commented on existing incident issue #${issues[0].number}`); + } else { + await github.rest.issues.create({ + owner: context.repo.owner, + repo: context.repo.repo, + title: issueTitle, + body: issueBody, + labels: [label] + }); + console.log('Created new incident issue'); + } diff --git a/README.md b/README.md index 0d582e0..7c46c5d 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,8 @@ The bootstrap command will guide you through the process of setting up a Supabas | **Swagger Docs** | https://stepfi-api.onrender.com/api/v1/docs | | **Health Check** | https://stepfi-api.onrender.com/api/v1/health | +> **Note**: A GitHub Action workflow pings the Health Check URL every 6 hours to keep the Render free tier instance warm and acts as a heartbeat monitor. If the ping fails (non-200 response), it automatically creates or updates a GitHub issue with the `incident` label to alert maintainers. + ## 🛠️ Error tracking Error tracking is powered by Sentry. To enable error tracking in development or production: diff --git a/context/progress-tracker.md b/context/progress-tracker.md index 3a5dd01..648f6d5 100644 --- a/context/progress-tracker.md +++ b/context/progress-tracker.md @@ -6,6 +6,11 @@ pure chore/docs commits). Direct pushes to main must also be logged here. --- +## 2026-07-23 + +- Added GitHub Actions health check workflow (`health-check.yml`) to ping the Render API every 6 hours to prevent the free tier instance from sleeping. Auto-creates or comments on issues with the `incident` label if the ping fails, preventing silent outages. +- Documented the ping URL and incident label in README. + ## 2026-07-19 - Wired `LiquidityContractClient` (restored under `src/blockchain/contracts/liquidity-contract.client.ts`) into `LiquidityService` constructor. From 2c8ad9271930aa2d55f6d9d4357e4777d1dd92ff Mon Sep 17 00:00:00 2001 From: EmeditWeb Date: Thu, 23 Jul 2026 16:29:34 +0100 Subject: [PATCH 2/2] ci(health-check): capture real HTTP status on failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use `curl -s` (not `-sf`) so the actual response code is captured on 4xx/5xx, and fall back to 000 on connection failure — so the auto-filed incident issue reports the real status instead of 'failed'. --- .github/workflows/health-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/health-check.yml b/.github/workflows/health-check.yml index 8bc829f..dc0c5c4 100644 --- a/.github/workflows/health-check.yml +++ b/.github/workflows/health-check.yml @@ -14,7 +14,7 @@ jobs: - name: Ping Health Endpoint id: ping run: | - status=$(curl -sf -o /dev/null -w "%{http_code}" https://stepfi-api.onrender.com/api/v1/health || echo "failed") + status=$(curl -s -o /dev/null -w "%{http_code}" https://stepfi-api.onrender.com/api/v1/health || echo "000") echo "status=$status" >> "$GITHUB_OUTPUT" - name: Handle Failure