REST root ping + cheap table/rpc query with the anon key, retries with backoff, job summary, early warnings (stale last success, weekly cron, GitHub 60-day schedule disable), copy-paste workflow examples and a curl-only fallback. Self-test workflow runs against a real endpoint. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
88 lines
3.5 KiB
YAML
88 lines
3.5 KiB
YAML
name: "Supabase Keep-Alive Ping"
|
|
description: "Keeps a free Supabase project from pausing: pings the REST API and runs a cheap query with the anon key, retries, writes a job summary, and warns before the 7-day window."
|
|
author: "caelum0x"
|
|
|
|
branding:
|
|
icon: "activity"
|
|
color: "green"
|
|
|
|
inputs:
|
|
url:
|
|
description: "Project URL, e.g. https://abcdefgh.supabase.co (store it as a secret or variable)."
|
|
required: true
|
|
anon-key:
|
|
description: "The project's anon (public) API key. Store it as a repository secret; it is masked in logs."
|
|
required: true
|
|
table:
|
|
description: "Optional table to read with select=<select>&limit=1. A table with RLS enabled and no anon policy still works: the query runs and returns []."
|
|
required: false
|
|
default: ""
|
|
select:
|
|
description: "Columns for the table read. Default * (limit=1 keeps it cheap)."
|
|
required: false
|
|
default: "*"
|
|
rpc:
|
|
description: "Optional Postgres function to call via POST /rest/v1/rpc/<name>. Create one with: create function keepalive_ping() returns text language sql stable as $$ select 'ok' $$;"
|
|
required: false
|
|
default: ""
|
|
rpc-body:
|
|
description: "JSON body for the rpc call."
|
|
required: false
|
|
default: "{}"
|
|
retries:
|
|
description: "Retries per request after the first attempt (exponential backoff, 2s, 4s, 8s...). Not retried: 4xx other than 429, and 540 (project paused)."
|
|
required: false
|
|
default: "3"
|
|
timeout:
|
|
description: "Per-request timeout in seconds."
|
|
required: false
|
|
default: "20"
|
|
warn-after-days:
|
|
description: "Warn when the last successful run of this workflow is older than this many days. Supabase pauses after about 7 idle days."
|
|
required: false
|
|
default: "5"
|
|
fail-on-paused:
|
|
description: "Fail the step when the project answers HTTP 540 (paused). Set to false to only warn."
|
|
required: false
|
|
default: "true"
|
|
github-token:
|
|
description: "Token used to read this workflow's previous runs, the repo's last push date and the cron schedule, for the early warnings. Needs actions: read and contents: read. Set to empty to skip those checks."
|
|
required: false
|
|
default: ${{ github.token }}
|
|
|
|
outputs:
|
|
status:
|
|
description: "ok, paused, or failed"
|
|
value: ${{ steps.ping.outputs.status }}
|
|
rest-status:
|
|
description: "HTTP status of GET /rest/v1/"
|
|
value: ${{ steps.ping.outputs.rest-status }}
|
|
query-status:
|
|
description: "HTTP status of the table read or rpc call (empty if neither was configured)"
|
|
value: ${{ steps.ping.outputs.query-status }}
|
|
paused:
|
|
description: "true when the project answered HTTP 540"
|
|
value: ${{ steps.ping.outputs.paused }}
|
|
last-success-days:
|
|
description: "Days since the previous successful run of this workflow (empty on the first run or when the token cannot read runs)"
|
|
value: ${{ steps.ping.outputs.last-success-days }}
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- id: ping
|
|
shell: bash
|
|
env:
|
|
INPUT_URL: ${{ inputs.url }}
|
|
INPUT_ANON_KEY: ${{ inputs.anon-key }}
|
|
INPUT_TABLE: ${{ inputs.table }}
|
|
INPUT_SELECT: ${{ inputs.select }}
|
|
INPUT_RPC: ${{ inputs.rpc }}
|
|
INPUT_RPC_BODY: ${{ inputs.rpc-body }}
|
|
INPUT_RETRIES: ${{ inputs.retries }}
|
|
INPUT_TIMEOUT: ${{ inputs.timeout }}
|
|
INPUT_WARN_AFTER_DAYS: ${{ inputs.warn-after-days }}
|
|
INPUT_FAIL_ON_PAUSED: ${{ inputs.fail-on-paused }}
|
|
INPUT_GITHUB_TOKEN: ${{ inputs.github-token }}
|
|
run: bash "${{ github.action_path }}/keepalive.sh"
|