-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b620b01
commit d203678
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Scheduled Health Check | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 0 */5 * *" # each 5 days | ||
|
||
jobs: | ||
health-check: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
HEALTHCHECK_URL: ${{ secrets.HEALTHCHECK_URL }} | ||
HEALTHCHECK_TOKEN: ${{ secrets.HEALTHCHECK_TOKEN }} | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "18" | ||
|
||
- name: Install Dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Run Health Check | ||
run: tsx scripts/check.ts |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
async function main() { | ||
const url = process.env.HEALTHCHECK_URL; | ||
|
||
if (url == null) { | ||
throw new Error("Healthcheck url is required"); | ||
} | ||
|
||
const res = await fetch(url, { | ||
headers: { | ||
Authorization: process.env.HEALTHCHECK_TOKEN || "", | ||
}, | ||
}); | ||
|
||
if (!res.ok) { | ||
throw new Error(`Request failed with status ${res.status}`); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const json = await res.json(); | ||
console.log(json); | ||
} | ||
|
||
main().catch(console.error); |