Skip to content

Rebrand Stan from Instagram to TikTok with updated pricing #1435

Rebrand Stan from Instagram to TikTok with updated pricing

Rebrand Stan from Instagram to TikTok with updated pricing #1435

Workflow file for this run

# neon ref: https://neon.tech/blog/branching-with-preview-environments
name: Preview
on:
pull_request:
merge_group:
types: [checks_requested]
jobs:
# 👾 GIT METADATA #
git-meta:
runs-on: ubuntu-latest
if: always() && github.event_name == 'pull_request'
outputs:
git_branch_name: ${{ steps.git-meta.outputs.github_commit_ref }}
github_commit_sha: ${{ steps.git-meta.outputs.github_commit_sha }}
github_commit_author_name: ${{ steps.git-meta.outputs.github_commit_author_name }}
github_commit_author_login: ${{ steps.git-meta.outputs.github_commit_author_login }}
github_deployment: ${{ steps.git-meta.outputs.github_deployment }}
github_org: ${{ steps.git-meta.outputs.github_org }}
github_repo: ${{ steps.git-meta.outputs.github_repo }}
github_commit_org: ${{ steps.git-meta.outputs.github_commit_org }}
github_commit_repo: ${{ steps.git-meta.outputs.github_commit_repo }}
github_commit_message: ${{ steps.git-meta.outputs.github_commit_message }}
github_commit_ref: ${{ steps.git-meta.outputs.github_commit_ref }}
vercel_git_metadata: ${{ steps.git-meta.outputs.vercel_git_metadata }}
db_changed: ${{ steps.db-changes.outputs.db_changed }}
tb_changed: ${{ steps.tb-changes.outputs.tb_changed }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- id: git-meta
run: |
github_commit_sha=${{ github.event.pull_request.head.sha }}
github_commit_author_login=${{ github.actor }}
github_deployment=1
github_org=${{ github.repository_owner }}
github_repo=${{ github.repository }}
github_commit_org=${{ github.repository_owner }}
github_commit_repo=${{ github.repository }}
github_commit_message=$(git show -s --format=%s $github_commit_sha)
github_commit_ref=${{ github.event.pull_request.head.ref }}
# Escape quotes in commit message for shell safety
escaped_commit_message=$(echo "$github_commit_message" | sed 's/"/\\"/g')
vercel_git_metadata="-m githubCommitSha=$github_commit_sha -m githubCommitAuthorName=$github_commit_author_login -m githubCommitAuthorLogin=$github_commit_author_login -m githubDeployment=$github_deployment -m githubOrg=$github_org -m githubRepo=$github_repo -m githubCommitOrg=$github_commit_org -m githubCommitRepo=$github_commit_repo -m githubCommitMessage=\"$escaped_commit_message\" -m githubCommitRef=$github_commit_ref"
echo "github_commit_sha=$github_commit_sha" >> $GITHUB_OUTPUT
echo "github_commit_author_name=$github_commit_author_name" >> $GITHUB_OUTPUT
echo "github_commit_author_login=$github_commit_author_login" >> $GITHUB_OUTPUT
echo "github_deployment=$github_deployment" >> $GITHUB_OUTPUT
echo "github_org=$github_org" >> $GITHUB_OUTPUT
echo "github_repo=$github_repo" >> $GITHUB_OUTPUT
echo "github_commit_org=$github_commit_org" >> $GITHUB_OUTPUT
echo "github_commit_repo=$github_commit_repo" >> $GITHUB_OUTPUT
echo "github_commit_message=$github_commit_message" >> $GITHUB_OUTPUT
echo "github_commit_ref=$github_commit_ref" >> $GITHUB_OUTPUT
echo "vercel_git_metadata=$vercel_git_metadata" >> $GITHUB_OUTPUT
- name: check for db/const changes
id: db-changes
run: |
# Get the base branch (usually main)
base_branch=${{ github.event.pull_request.base.ref }}
# Fetch the base branch to ensure we have it locally
git fetch origin $base_branch
# Check if there are changes in packages/db or packages/const
if git diff --name-only origin/$base_branch...HEAD | grep -E "^packages/(db|const)/" > /dev/null; then
echo "db_changed=true" >> $GITHUB_OUTPUT
echo "Changes detected in packages/db or packages/const"
else
echo "db_changed=false" >> $GITHUB_OUTPUT
echo "No changes detected in packages/db or packages/const"
fi
- name: check for tinybird changes
id: tb-changes
run: |
# Get the base branch (usually main)
base_branch=${{ github.event.pull_request.base.ref }}
# Check if there are changes in packages/tb/tinybird
if git diff --name-only origin/$base_branch...HEAD | grep -E "^packages/tb/tinybird/" > /dev/null; then
echo "tb_changed=true" >> $GITHUB_OUTPUT
echo "Changes detected in packages/tb/tinybird"
else
echo "tb_changed=false" >> $GITHUB_OUTPUT
echo "No changes detected in packages/tb/tinybird"
fi
# 🐘 NEON DB PREVIEW #
neon-preview:
name: neon preview
if: always() && github.event_name == 'pull_request'
needs: [git-meta]
runs-on: ubuntu-latest
env:
VERCEL_ACCESS_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_APP_PROJECT_ID }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_TEAM_ID }}
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: setup node/pnpm/turbo/vercel
uses: ./tooling/github/setup
- name: install neon cli
run: pnpm i -g neonctl
# This is just so the env check doesn't fail on missing variables.
# DATABASE_URL && DATABASE_POOL_URL will be overwritten below.
- name: copy env
shell: bash
run: cp .env.example .env
# If the branch already exists, this command will fail but the workflow will continue
- id: create-branch
run: |
output=$(neonctl branches create --project-id ${{ secrets.NEON_PROJECT_ID }} --name ${{ needs.git-meta.outputs.git_branch_name }} --api-key ${{ secrets.NEON_API_KEY }} --compute --type read_write 2>&1) || true
if [[ $output == *"branch with the provided name \"${{ needs.git-meta.outputs.git_branch_name }}\" already exists"* ]]; then
echo "A branch named \"${{ needs.git-meta.outputs.git_branch_name }}\" already exists. Using that branch for this preview deployment."
elif [[ $output == *"error:"* || $output == *"severity: 'ERROR'"* ]]; then
echo "Unhandled error: $output" && exit 1
fi
# The branch ID is needed to display the URL of the branch in the comment.
- id: get-neon-branch
run: |
branch_id=$(neonctl branches get ${{ needs.git-meta.outputs.git_branch_name }} --project-id ${{ secrets.NEON_PROJECT_ID }} --api-key ${{ secrets.NEON_API_KEY }} --output json | jq -r '.id')
echo "branch_id=$branch_id" >> $GITHUB_ENV
DATABASE_URL=$(neonctl connection-string ${{ needs.git-meta.outputs.git_branch_name }} --project-id ${{ secrets.NEON_PROJECT_ID }} --role-name ${{ secrets.PG_USERNAME }} --database-name ${{ secrets.PG_DATABASE }} --api-key ${{ secrets.NEON_API_KEY }} | tr -d '\n')?sslmode=require
echo "DATABASE_URL=$DATABASE_URL" >> $GITHUB_ENV
DATABASE_POOL_URL=$(neonctl connection-string ${{ needs.git-meta.outputs.git_branch_name }} --pooled --project-id ${{ secrets.NEON_PROJECT_ID }} --role-name ${{ secrets.PG_USERNAME }} --database-name ${{ secrets.PG_DATABASE }} --api-key ${{ secrets.NEON_API_KEY }} | tr -d '\n')?sslmode=require
echo "DATABASE_POOL_URL=$DATABASE_POOL_URL" >> $GITHUB_ENV
- name: db:push
if: needs.git-meta.outputs.db_changed == 'true'
run: |
rm -f .env
touch .env
echo "DATABASE_URL: $DATABASE_URL"
echo "DATABASE_POOL_URL: $DATABASE_POOL_URL"
echo "DATABASE_URL=$DATABASE_URL" >> .env
echo "DATABASE_POOL_URL=$DATABASE_POOL_URL" >> .env
# Run db:push with timeout to prevent hanging on interactive prompts
output=$(timeout 180s bash -c 'echo "n" | pnpm db:push' 2>&1) || {
echo "ERROR: db:push timed out or failed - likely requires interactive input"
echo "output: $output"
echo "Please run 'pnpm db:push' locally to handle any schema ambiguities"
exit 1
}
echo "output: $output"
# Check for successful completion
if [[ $output != *"[✓] Changes applied"* ]] && [[ $output != *"No changes detected"* ]]; then
echo "ERROR: db:push did not complete successfully"
echo "Expected to see '[✓] Changes applied' or 'No changes detected' in output"
# Check for known interactive prompt patterns
if [[ $output == *"?"* ]] || [[ $output == *"›"* ]] || [[ $output == *"❯"* ]]; then
echo "Detected interactive prompt - manual intervention required"
echo "Please run 'pnpm db:push' locally to handle schema changes"
fi
exit 1
fi
echo "db:push completed successfully"
- name: skip db:push message
if: needs.git-meta.outputs.db_changed == 'false'
run: |
echo "Skipping db:push - no changes detected in packages/db or packages/const"
echo "Using existing Neon branch database schema"
# Using Vercel as our secret store for the DATABASE_URL and DATABASE_POOL_URL
# -- to my knowledge, using an external store is the only way to pass secrets between Github Actions jobs?
- name: update vercel env - app/preview/branch
run: |
echo "DATABASE_URL: $DATABASE_URL"
echo "DATABASE_POOL_URL: $DATABASE_POOL_URL"
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
echo "Removing existing DATABASE_URL env variable from preview branch (git branch: $branch_name)"
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
echo "Removing existing DATABASE_POOL_URL env variable from preview branch (git branch: $branch_name)"
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
- name: update vercel env - app-fm/preview/branch
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_APP_FM_PROJECT_ID }}
run: |
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
- name: update vercel env - app-invoice/preview/branch
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_APP_INVOICE_PROJECT_ID }}
run: |
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
- name: update vercel env - cart/preview/branch
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_CART_PROJECT_ID }}
run: |
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
- name: update vercel env - fm/preview/branch
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_FM_PROJECT_ID }}
run: |
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
- name: update vercel env - invoice/preview/branch
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_INVOICE_PROJECT_ID }}
run: |
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
- name: update vercel env - link/preview/branch
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_LINK_PROJECT_ID }}
run: |
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
- name: update vercel env - manage-email/preview/branch
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_MANAGE_EMAIL_PROJECT_ID }}
run: |
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
- name: update vercel env - page/preview/branch
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PAGE_PROJECT_ID }}
run: |
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
- name: update vercel env - press/preview/branch
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PRESS_PROJECT_ID }}
run: |
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
- name: update vercel env - nyc/preview/branch
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_NYC_PROJECT_ID }}
run: |
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
- name: update vercel env - vip/preview/branch
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_VIP_PROJECT_ID }}
run: |
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
- name: update vercel env - www/preview/branch
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_WWW_PROJECT_ID }}
run: |
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
- name: update vercel env - bio/preview/branch
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_BIO_PROJECT_ID }}
run: |
branch_name=${{ needs.git-meta.outputs.git_branch_name }}
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_URL; then
pnpm vercel env rm DATABASE_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
if pnpm vercel env ls preview $branch_name --token=${{ secrets.VERCEL_TOKEN }} | grep -q DATABASE_POOL_URL; then
pnpm vercel env rm DATABASE_POOL_URL preview $branch_name --yes --token=${{ secrets.VERCEL_TOKEN }}
fi
echo $DATABASE_URL | pnpm vercel env add DATABASE_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
echo $DATABASE_POOL_URL | pnpm vercel env add DATABASE_POOL_URL preview $branch_name --token=${{ secrets.VERCEL_TOKEN }}
outputs:
neon_branch_id: ${{ steps.get-neon-branch.outputs.branch_id }}
# 🔄 TRIGGER PREVIEW #
trigger-preview:
name: trigger staging
if: always() && github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: setup node/pnpm/turbo/vercel
uses: ./tooling/github/setup
- name: deploy trigger.dev
env:
TRIGGER_ACCESS_TOKEN: ${{ secrets.TRIGGER_ACCESS_TOKEN }}
run: |
cd packages/lib && pnpm dlx trigger.dev@3.3.17 deploy --env staging
# 👀 DEPLOY PREVIEWS
deploy-app:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: app
working_directory: apps/app
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_APP_PROJECT_ID }}
deploy-app-fm:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: app
working_directory: apps/app
current_app_override: fm
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_APP_FM_PROJECT_ID }}
deploy-app-invoice:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: app
working_directory: apps/app
current_app_override: invoice
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_APP_INVOICE_PROJECT_ID }}
deploy-bio:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: bio
working_directory: apps/bio
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_BIO_PROJECT_ID }}
deploy-cart:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: cart
working_directory: apps/cart
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_CART_PROJECT_ID }}
deploy-link:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: link
working_directory: apps/link
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_LINK_PROJECT_ID }}
deploy-fm:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: fm
working_directory: apps/fm
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_FM_PROJECT_ID }}
deploy-invoice:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: invoice
working_directory: apps/invoice
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_INVOICE_PROJECT_ID }}
deploy-manage-email:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: manage-email
working_directory: apps/manage-email
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_MANAGE_EMAIL_PROJECT_ID }}
deploy-nyc:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: nyc
working_directory: apps/nyc
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_NYC_PROJECT_ID }}
deploy-page:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: page
working_directory: apps/page
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PAGE_PROJECT_ID }}
deploy-press:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: press
working_directory: apps/press
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PRESS_PROJECT_ID }}
deploy-vip:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: vip
working_directory: apps/vip
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_VIP_PROJECT_ID }}
deploy-www:
uses: ./.github/workflows/deploy-to-vercel.yml
needs: [git-meta, neon-preview]
with:
app_name: www
working_directory: apps/www
scope: barely
environment: preview
git_branch: ${{ needs.git-meta.outputs.git_branch_name }}
vercel_git_metadata: ${{ needs.git-meta.outputs.vercel_git_metadata }}
delay_seconds: 0
secrets:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
VERCEL_TEAM_ID: ${{ secrets.VERCEL_TEAM_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_WWW_PROJECT_ID }}
# 💬 COMMENT ON PR #
comment:
if: always() && github.event_name == 'pull_request'
needs:
[
neon-preview,
deploy-app,
deploy-app-fm,
deploy-app-invoice,
deploy-bio,
deploy-cart,
deploy-link,
deploy-fm,
deploy-invoice,
deploy-manage-email,
deploy-nyc,
deploy-page,
deploy-press,
deploy-vip,
deploy-www,
]
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: checkout
uses: actions/checkout@v4
- name: comment on pull request
uses: thollander/actions-comment-pull-request@v2
with:
message: |
## apps
| :iphone: app | :rocket: preview | :mag: inspect |
| ------------ | ---------------- | ------------- |
| :iphone: app | [preview](${{ needs.deploy-app.outputs.deployment_url }}) | [inspect](${{ needs.deploy-app.outputs.inspect_url }}) |
| :radio: app-fm | [preview](${{ needs.deploy-app-fm.outputs.deployment_url }}) | [inspect](${{ needs.deploy-app-fm.outputs.inspect_url }}) |
| :receipt: app-invoice | [preview](${{ needs.deploy-app-invoice.outputs.deployment_url }}) | [inspect](${{ needs.deploy-app-invoice.outputs.inspect_url }}) |
| :seedling: bio | [preview](${{ needs.deploy-bio.outputs.deployment_url }}) | [inspect](${{ needs.deploy-bio.outputs.inspect_url }}) |
| :shopping_cart: cart | [preview](${{ needs.deploy-cart.outputs.deployment_url }}) | [inspect](${{ needs.deploy-cart.outputs.inspect_url }}) |
| :radio: fm | [preview](${{ needs.deploy-fm.outputs.deployment_url }}) | [inspect](${{ needs.deploy-fm.outputs.inspect_url }}) |
| :receipt: invoice | [preview](${{ needs.deploy-invoice.outputs.deployment_url }}) | [inspect](${{ needs.deploy-invoice.outputs.inspect_url }}) |
| :link: link | [preview](${{ needs.deploy-link.outputs.deployment_url }}) | [inspect](${{ needs.deploy-link.outputs.inspect_url }}) |
| :email: manage-email | [preview](${{ needs.deploy-manage-email.outputs.deployment_url }}) | [inspect](${{ needs.deploy-manage-email.outputs.inspect_url }}) |
| :city_sunset: nyc | [preview](${{ needs.deploy-nyc.outputs.deployment_url }}) | [inspect](${{ needs.deploy-nyc.outputs.inspect_url }}) |
| :page_facing_up: page | [preview](${{ needs.deploy-page.outputs.deployment_url }}) | [inspect](${{ needs.deploy-page.outputs.inspect_url }}) |
| :newspaper: press | [preview](${{ needs.deploy-press.outputs.deployment_url }}) | [inspect](${{ needs.deploy-press.outputs.inspect_url }}) |
| :star: vip | [preview](${{ needs.deploy-vip.outputs.deployment_url }}) | [inspect](${{ needs.deploy-vip.outputs.inspect_url }}) |
| :globe_with_meridians: www | [preview](${{ needs.deploy-www.outputs.deployment_url }}) | [inspect](${{ needs.deploy-www.outputs.inspect_url }}) |
## db
| :floppy_disk: db | :mag: inspect |
| ---------------- | ------------- |
| :elephant: neon | [inspect](${{ needs.neon-preview.outputs.neon_branch_id }}) |
preview--can-merge:
needs:
[
neon-preview,
trigger-preview,
deploy-app,
deploy-app-fm,
deploy-app-invoice,
deploy-bio,
deploy-cart,
deploy-fm,
deploy-invoice,
deploy-link,
deploy-manage-email,
deploy-nyc,
deploy-page,
deploy-press,
deploy-vip,
deploy-www,
]
if: always() && github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
actions: read
steps:
- name: Transform outcomes
env:
NEEDS_JSON: '${{ toJson(needs) }}'
run: |
echo "ALL_SUCCESS=$(echo "$NEEDS_JSON" | jq '. | to_entries | map([.value.result == "success", .value.result == "skipped"] | any) | all')" >> $GITHUB_ENV
- name: Check outcomes
run: '[ $ALL_SUCCESS = true ]'