Repository: supabase/cli

Issue #45: How to use Supabase CLI with GitHub Actions?
Created: 2021-08-02T00:51:08Z
Bug report
Describe the bug
As far as I know, there's no way to use the Supabase CLI in a continuous integration environment like GitHub Actions without checking the automatically generated .supabase/ directory into version control.
Running supabase init in a CI environment just results in nothing (because your CI can't answer its prompts):
Run yarn supabase init
25l25l? Port for Supabase URL: ‣ 800025h25h

And then, because supabase init did nothing and thus didn't create the .supabase/ directory, running supabase start fails:
Run yarn start:sb
.FileNotFoundError: [Errno 2] No such file or directory: './.supabase/docker/docker-compose.yml'
Error: Process completed with exit code 1.

To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:

Create a new GitHub action.
Run supabase init
Run supabase start
See error.

Expected behavior
There should be documentation and CLI options for running in continuous integration environments like GitHub Actions.
Screenshots
If applicable, add screenshots to help explain your problem.

System information

OS: Ubuntu 20.04 LTS on GitHub Actions
Version of supabase-js: 1.21.0
Version of Node.js: 12.22.3

Additional context
I'm trying to get the checks working for this PR: tutorbookapp/tutorbook#228
And then this is one of the failed runs: https://github.com/tutorbookapp/tutorbook/runs/3216189922?check_suite_focus=true

Duplicate issue #147: GitHub Actions with CLI
Created: 2022-01-20T17:42:26Z
Improve documentation
Link
https://github.com/supabase/cli/tree/main/examples/tour
Describe the problem
No steps or docs on CI with CLI/migrations
Describe the improvement
I would like to add a section on how to setup GitHub to these docs
Hello,
I was wondering how I would make a CI flow with GitHub Actions.
The basic flow is the following:
(all after the installing, init, and start)

Local Changes to DB
Supabase CLI: supabase db commit 
Commit to source control (git)
Open a PR and reviewed
Once merged into the master/main branch, Github Actions runs a migration to Supabase project DB

I have come up with the following yml for the flow:
name: Migration for Prod DB

on:
  push:
    branches: [ master ]

jobs:
  changes:
    runs-on: ubuntu-latest
    outputs:
      migrations: ${{ steps.filter.outputs.migrations }}
    steps:
    - uses: dorny/paths-filter@v2
      id: filter
      with:
        filters: |
          migrations:
            - 'supabase/migrations/**'

  migration:
    needs: changes
    if: ${{ needs.changes.outputs.migrations == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install Supabase CLI
        run: brew install supabase/tap/supabase
      - name: Set Remote DB
        shell: bash
        env:
          SUPABASE_PASSWORD: ${{ secrets.SUPABASE_PASSWORD }}
          SUPABASE_PROJECT_REF: ${{ secrets.SUPABASE_PROJECT_REF }}
        run: |
          supabase db remote set 'postgresql://postgres:"$SUPABASE_PASSWORD"@db."$SUPABASE_PROJECT_REF".supabase.co:5432/postgres'
      - name: Push Migrations
        run: supabase db push
Would this be the approach to take? If so, I will make a PR for it in the docs

Closing comment (2022-08-06T13:14:39Z): We now have a GitHub Action app which documents how to setup Supabase CLI on your action runners. One benefit over brew install is that you can pin specific versions of the CLI for more reproducible builds.
Feel free to open new issues if you run into problems.
duplicates #45