README
¶
pingSupabse
Français / French & English version included below.
FRANÇAIS
Petit utilitaire en Go pour "ping" la base Supabase (Postgres) et garder l'instance éveillée. Le script peut aussi envoyer des notifications vers Slack via un webhook.
Résumé
- Langage : Go
- Fichier principal :
main.go(ping DB, notifications Slack) - CI : GitHub Actions (
.github/workflows/main.yml) — workflow programmé toutes les 48h et exécutable manuellement
Prérequis
- Go 1.25+ installé (local)
- Une base Supabase (DATABASE_URL)
- (Optionnel) Un webhook Slack pour recevoir les notifications (SLACK_WEBHOOK_URL)
Installation
- Cloner le dépôt :
git clone https://github.com/Urielle122/pingSupabse.git
cd pingSupabse
- Installer les dépendances Go :
go mod tidy
Configuration
Créez un fichier .env à la racine (utile en local) avec au minimum :
DATABASE_URL=postgres://user:password@host:port/dbname
# Optionnel: webhook Slack pour notifications
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXX/YYY/ZZZ
Un exemple prêt à l’usage est fourni dans .env.example.
En production (GitHub Actions), définissez DATABASE_URL et SLACK_WEBHOOK_URL dans les Secrets du dépôt (voir la section "How to set GitHub Secrets" plus bas).
Usage
- Exécution locale :
go run main.go
- Comportement :
- Le programme tente de se connecter à la base et de faire un
Ping. - Il réessaie jusqu'à 3 fois (
maxRetries) avec 10s de pause entre chaque tentative. - En cas de succès/échec, il envoie une notification Slack si
SLACK_WEBHOOK_URLest défini.
- Le programme tente de se connecter à la base et de faire un
GitHub Actions
Le workflow .github/workflows/main.yml exécute le script toutes les 48 heures et peut aussi être déclenché manuellement. Il utilise les secrets DATABASE_URL et SLACK_WEBHOOK_URL.
How to set GitHub Secrets (FR)
- Va dans ton dépôt sur GitHub > "Settings" > "Secrets and variables" > "Actions".
- Clique sur "New repository secret".
- Ajoute
DATABASE_URLcomme nom et colle ta chaîne de connexion Supabase comme valeur. - (Optionnel) Ajoute
SLACK_WEBHOOK_URLavec l'URL du webhook Slack. - Clique sur "Add secret". Les secrets sont chiffrés et disponibles seulement pour les workflows Actions.
Notes de sécurité :
- Ne commite jamais une chaîne de connexion ou un webhook directement dans le dépôt.
- Utilise les Secrets GitHub pour protéger ces valeurs dans CI.
Variables d'environnement
DATABASE_URL(obligatoire) : chaîne de connexion Postgres vers SupabaseSLACK_WEBHOOK_URL(optionnel) : URL du webhook Slack pour notifications
Débogage / FAQ
- Erreur "DATABASE_URL non définie" : vérifiez que la variable d'environnement est bien définie localement ou dans les Secrets GitHub.
- Notifications Slack non envoyées : vérifiez que le webhook est correct. Les erreurs sont loggées côté action.
Licence
Ce dépôt contient un fichier LICENSE (par défaut proposé : MIT) — voir section Licence en bas.
Contribuer Les contributions sont bienvenues : ouvre une issue ou une PR.
ENGLISH
Small Go tool to "ping" a Supabase (Postgres) database to keep the instance awake. The script can also send Slack notifications via an incoming webhook.
Summary
- Language: Go
- Main file:
main.go(DB ping + Slack notifications) - CI: GitHub Actions (
.github/workflows/main.yml) — runs every 48h and is manually triggerable
Prerequisites
- Go 1.25+ (local)
- A Supabase database (DATABASE_URL)
- (Optional) Slack webhook for notifications (SLACK_WEBHOOK_URL)
Install
- Clone the repo:
git clone https://github.com/Urielle122/pingSupabse.git
cd pingSupabse
- Install Go dependencies:
go mod tidy
Configuration
Create a .env file at the project root (useful locally) with at least:
DATABASE_URL=postgres://user:password@host:port/dbname
# Optional: Slack webhook for notifications
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/XXX/YYY/ZZZ
A ready-to-use example is included as .env.example.
In production (GitHub Actions), set DATABASE_URL and SLACK_WEBHOOK_URL in the repository Secrets (see "How to set GitHub Secrets" below).
Usage
- Run locally:
go run main.go
- Behavior:
- The program connects to the DB and performs a
Ping. - It retries up to 3 times (
maxRetries) with 10s delay between attempts. - On success/failure it sends a Slack notification if
SLACK_WEBHOOK_URLis set.
- The program connects to the DB and performs a
How to set GitHub Secrets (EN)
- Go to your repository on GitHub > "Settings" > "Secrets and variables" > "Actions".
- Click "New repository secret".
- Add
DATABASE_URLas the name and paste your Supabase connection string as the value. - (Optional) Add
SLACK_WEBHOOK_URLwith the incoming Slack webhook URL. - Click "Add secret". Secrets are encrypted and only available to Actions workflows.
Security notes:
- Never commit connection strings or webhooks into the repo.
- Use GitHub Secrets to protect these values in CI.
Environment variables
DATABASE_URL(required) : Postgres connection string to SupabaseSLACK_WEBHOOK_URL(optional) : Slack incoming webhook URL for notifications
Troubleshooting / FAQ
- "DATABASE_URL not set" error: ensure the env var is set locally or in GitHub Secrets.
- Slack notifications not sent: verify the webhook; errors are logged by the action.
License
This repository includes a LICENSE file (suggested: MIT). See LICENSE for details.
Contributing Contributions are welcome — open an issue or a PR.
Notes
- I updated README with extra badges and a detailed section explaining how to set GitHub Secrets.
Documentation
¶
There is no documentation for this package.