Skip to content

Commit 2716958

Browse files
committed
feat(ci): Cache and start Supabase in CI workflow
- Cache Supabase Docker images (/var/lib/docker) using actions/cache with a key based on supabase/config.toml - Start Supabase locally in the background and export API URL, anon key, and service role key to GITHUB_ENV - Wait briefly before running the build to allow Supabase to start
1 parent 399c58a commit 2716958

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,26 @@ jobs:
2222
- name: Install dependencies
2323
run: npm ci
2424

25+
- name: Cache Supabase Docker images
26+
uses: actions/cache@v4
27+
with:
28+
path: /var/lib/docker
29+
key: ${{ runner.os }}-supabase-docker-${{ hashFiles('supabase/config.toml') }}
30+
restore-keys: |
31+
${{ runner.os }}-supabase-docker-
32+
33+
- name: Start Supabase locally in background
34+
run: |
35+
npx --yes supabase start
36+
SUPABASE_URL=$(npx --yes supabase status --output env | awk -F= '/API_URL/ {gsub(/"/,"",$2); print $2}')
37+
SUPABASE_ANON_KEY=$(npx --yes supabase status --output env | awk -F= '/PUBLISHABLE_KEY/ {gsub(/"/,"",$2); print $2}')
38+
SUPABASE_SERVICE_ROLE_KEY=$(npx --yes supabase status --output env | awk -F= '/SERVICE_ROLE_KEY/ {gsub(/"/,"",$2); print $2}')
39+
40+
echo "NEXT_PUBLIC_SUPABASE_URL=$SUPABASE_URL" >> $GITHUB_ENV
41+
echo "NEXT_PUBLIC_SUPABASE_ANON_KEY=$SUPABASE_ANON_KEY" >> $GITHUB_ENV
42+
echo "SUPABASE_SERVICE_ROLE_KEY=$SUPABASE_SERVICE_ROLE_KEY" >> $GITHUB_ENV
43+
44+
sleep 15 # wait
45+
2546
- name: Build project
2647
run: npm run build

0 commit comments

Comments
 (0)