A Github Action to return the Supabase preview branch URL and credentials for a given Supabase project.
Find out more about Supabase Branching by reading the official docs here.
This action is a wrapper around the Supabase Management API.
Not officially endorsed by Supabase.
All outputs except api_url and graphql_url will be masked in the GitHub Actions logs.
Basic usage:
- uses: 0xbigboss/supabase-branch-gh-action@v1
id: supabase-branch
with:
supabase-access-token: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
supabase-project-id: ${{ secrets.SUPABASE_PROJECT_ID }}
git-branch: "sb-preview-branch" # Optional
wait-for-migrations: true # Optional. Default is false.
timeout: 60 # Optional. Default is 60.
- name: Get result
run: |
echo "ref=${{steps.supabase-branch.outputs.ref}}"
echo "api_url=${{steps.supabase-branch.outputs.api_url}}"
echo "graphql_url=${{steps.supabase-branch.outputs.graphql_url}}"
echo "db_host=${{steps.supabase-branch.outputs.db_host}}"
echo "db_port=${{steps.supabase-branch.outputs.db_port}}"
echo "db_user=${{steps.supabase-branch.outputs.db_user}}"
echo "db_password=${{steps.supabase-branch.outputs.db_password}}"
echo "jwt_secret=${{steps.supabase-branch.outputs.jwt_secret}}"
echo "anon_key=${{steps.supabase-branch.outputs.anon_key}}"
echo "service_role_key=${{steps.supabase-branch.outputs.service_role_key}}"
To install dependencies:
bun install
Make some changes and then run:
bun run build
Commit the changes and push!
You can mock the action environment by running it like so:
process.env[
`INPUT_${"supabase-access-token".replace(/ /g, "_").toUpperCase()}`
] = process.env.SUPABASE_ACCESS_TOKEN;
process.env[`INPUT_${"supabase-project-id".replace(/ /g, "_").toUpperCase()}`] =
process.env.SUPABASE_PROJECT_ID;
process.env[`INPUT_${"wait-for-migrations".replace(/ /g, "_").toUpperCase()}`] =
"false";
process.env[`INPUT_${"timeout".replace(/ /g, "_").toUpperCase()}`] = "60";
await main();
This project was created using bun init
in bun v1.0.29. Bun is a fast all-in-one JavaScript runtime.