Skip to content

test(repo): CI & docker caching optimizations, nx-aware infra, reliability fixes #1179

test(repo): CI & docker caching optimizations, nx-aware infra, reliability fixes

test(repo): CI & docker caching optimizations, nx-aware infra, reliability fixes #1179

name: Preview release
permissions:
pull-requests: write
on:
pull_request:
types: [opened, synchronize]
paths:
- 'packages/core/**'
- 'package.json'
- 'package-lock.json'
- 'nx.json'
- 'tsconfig.base.json'
- 'scripts/**'
- '.github/workflows/preview-release.yml'
- '.github/workflows/integration-tests.yml'
- '!packages/core/**/*.md'
- '!packages/core/**/docs/**'
- '!packages/core/**/.prettierrc'
- '!packages/core/**/*ignore'
jobs:
preview:
if: github.repository == 'supabase/supabase-js'
runs-on: ubuntu-latest
outputs:
commit_hash: ${{ steps.commit.outputs.sha }}
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
filter: tree:0
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Set up Nx SHAs
uses: nrwl/nx-set-shas@3e9ad7370203c1e93d109be57f3b72eb0eb511b1 # v4.4.0
- name: Build all packages
run: npx nx run-many --target=build --all
- name: Publish preview packages
run: |
npx pkg-pr-new@latest publish --compact \
./packages/core/auth-js \
./packages/core/functions-js \
./packages/core/postgrest-js \
./packages/core/realtime-js \
./packages/core/storage-js \
./packages/core/supabase-js \
2>&1 | tee /tmp/pkg-pr-new-output.txt
- name: Get commit hash
id: commit
run: |
# Extract the SHA from pkg.pr.new URLs in the output
# Lines look like: npm i https://pkg.pr.new/@supabase/supabase-js@49b3c56
echo "--- pkg-pr-new captured output ---"
cat /tmp/pkg-pr-new-output.txt
echo "--- end of captured output ---"
COMMIT_SHA=$(grep -oE 'pkg\.pr\.new/\S+@[a-f0-9]+' /tmp/pkg-pr-new-output.txt | head -1 | grep -oE '[a-f0-9]+$' || true)
if [ -z "$COMMIT_SHA" ]; then
echo "::warning::Failed to parse commit SHA from pkg-pr-new output, falling back to PR head SHA"
COMMIT_SHA="${{ github.event.pull_request.head.sha }}"
fi
echo "sha=$COMMIT_SHA" >> "$GITHUB_OUTPUT"
echo "Commit SHA for pkg.pr.new URLs: $COMMIT_SHA"
integration-tests:
name: Run Integration Tests
needs: preview
uses: ./.github/workflows/integration-tests.yml
with:
commit_hash: ${{ needs.preview.outputs.commit_hash }}