1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【React】Github Actions supabaseUrl is requiredの解決方法について

Posted at

はじめに

GithubのCIでjestのテストでsupabaseUrl is required.が表示されることについて、こちらの解決方法について記事にします。

次のような表示がActionsに表示されsupabaseの環境変数が読み込めていないようでした。

  supabaseUrl is required.

 export const supabase = createClient<Database>(
        |                                     ^
      6 |   process.env.VITE_SUPABASE_URL!,
      7 |   process.env.VITE_SUPABASE_ANON_KEY!
      8 | );

【修正前のコード】
github-test.yml

name: Jest use test
on: push

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install dependencies
        run: npm ci

      - name: Run tests with Makefile
        run: make test

解決方法

envで環境変数が読み込まれるようにする

github-test.yml
name: Jest use test
on: push

jobs:
  test:
    runs-on: ubuntu-latest

    env:
      VITE_SUPABASE_URL: ${{ secrets.VITE_SUPABASE_URL }}
      VITE_SUPABASE_ANON_KEY: ${{ secrets.VITE_SUPABASE_ANON_KEY }}

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install dependencies
        run: npm ci

      - name: Run tests with Makefile
        run: make test

参考

おわりに

過去にも同じ箇所でつまずいた記憶があり、今回記事にしました。


1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?