fix(deps): update all non-major dependencies #157
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Preview | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
env: | |
SKIP_ENV_VALIDATION: 1 | |
jobs: | |
build-lint: | |
if: "!contains(github.head_ref, 'renovate/')" | |
uses: ./.github/workflows/job_build.yaml | |
with: | |
pull_secrets: true | |
project_slug: unprice-zq-xm | |
env_slug: preview | |
secrets: | |
MACHINE_IDENTITY_CLIENT_ID: ${{ secrets.MACHINE_IDENTITY_CLIENT_ID }} | |
MACHINE_IDENTITY_CLIENT_SECRET: ${{ secrets.MACHINE_IDENTITY_CLIENT_SECRET }} | |
deploy-preview: | |
if: "!contains(github.head_ref, 'renovate/')" | |
runs-on: ubuntu-latest | |
needs: | |
- build-lint | |
permissions: | |
pull-requests: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: Infisical/[email protected] | |
name: Pull secrets from Infisical | |
with: | |
client-id: ${{ secrets.MACHINE_IDENTITY_CLIENT_ID }} | |
client-secret: ${{ secrets.MACHINE_IDENTITY_CLIENT_SECRET }} | |
env-slug: "preview" | |
project-slug: "unprice-zq-xm" | |
export-type: "file" | |
file-output-path: "/.env" | |
secret-path: "/" | |
recursive: true | |
- uses: ./.github/actions/install | |
with: | |
ts: true | |
- uses: cardinalby/export-env-action@v2 | |
with: | |
envFile: '.env' | |
export: true | |
# export everything except DATABASE_URL using regex | |
filter: ^(?!DATABASE_URL$).*$ | |
mask: true | |
- name: Get branch name | |
id: branch-name | |
uses: tj-actions/branch-names@v8 | |
- name: Create Neon Branch | |
id: create-branch | |
uses: neondatabase/create-branch-action@v5 | |
with: | |
project_id: ${{ env.NEON_PROJECT_ID }} | |
parent: main | |
branch_name: preview/pr-${{ steps.branch-name.outputs.current_branch }} | |
database: ${{ env.NEON_DATABASE_NAME }} | |
api_key: ${{ env.NEON_API_KEY }} | |
username: ${{ env.NEON_DATABASE_USERNAME }} | |
- name: Run Migrations | |
working-directory: internal/db | |
run: | | |
pnpm generate | |
pnpm migrate:custom | |
env: | |
VERCEL_ENV: preview | |
NODE_ENV: development | |
DATABASE_URL: ${{ steps.create-branch.outputs.db_url_with_pooler }} | |
- name: commit migrations | |
working-directory: internal/db | |
run: | | |
if [ -n "$(git status --porcelain ./)" ]; then | |
echo "Changes detected in db folder, committing..." | |
git config --global user.email "[email protected]" | |
git config --global user.name "Unprice Bot" | |
git add . | |
git commit -m "Migrations for preview" | |
git push --set-upstream origin ${{ steps.branch-name.outputs.current_branch }} | |
else | |
echo "No changes detected in db folder, skipping commit" | |
fi | |
- name: Schema Diff | |
uses: neondatabase/schema-diff-action@v1 | |
with: | |
project_id: ${{ env.NEON_PROJECT_ID }} | |
base_branch: main | |
compare_branch: preview/pr-${{ steps.branch-name.outputs.current_branch }} | |
username: ${{ env.NEON_DATABASE_USERNAME }} | |
database: ${{ env.NEON_DATABASE_NAME }} | |
api_key: ${{ env.NEON_API_KEY }} | |
- name: verify auth-proxy turbo-ignore | |
# verify if auth-proxy has changed, if it has, we need to deploy it | |
run: | | |
# If the command exits with code 1, the build continues as normal | |
# If the command exits with code 0, the build is immediately aborted | |
check=$(npx turbo-ignore -d apps/auth-proxy) || true | |
# if check has Proceeding with deployment string, we need to deploy it use grep | |
if echo "$check" | grep -q "Proceeding with deployment"; then | |
echo "Proceeding with deployment, deploying auth-proxy" | |
echo "deploy_auth_proxy=true" >> $GITHUB_OUTPUT | |
else | |
echo "No changes detected in auth-proxy folder, skipping build" | |
echo "deploy_auth_proxy=false" >> $GITHUB_OUTPUT | |
fi | |
- uses: amondnet/[email protected] #deploy | |
name: Deploy Unprice auth to Vercel | |
id: deploy-auth | |
if: ${{ steps.verify-auth-proxy.outputs.deploy_auth_proxy == 'true' }} | |
with: | |
vercel-token: ${{ env.VERCEL_TOKEN }} # Required | |
vercel-org-id: ${{ env.VERCEL_ORG_ID}} #Required | |
vercel-project-id: ${{ env.VERCEL_PROJECT_AUTH_UNPRICE_ID }} #Required | |
# always prod because the auth proxy link has to be stable | |
vercel-args: '--env "VERCEL_ENV=production" --env "VERCEL=true" --env "NODE_ENV=production" --prod --build-env "VERCEL_ENV=production" --build-env "VERCEL=true" --build-env "NODE_ENV=production"' | |
working-directory: ./ | |
# deploy preview unprice to vercel | |
- uses: amondnet/[email protected] #deploy | |
name: Deploy Preview Unprice to Vercel | |
id: deploy-unprice | |
with: | |
vercel-token: ${{ env.VERCEL_TOKEN }} # Required | |
vercel-org-id: ${{ env.VERCEL_ORG_ID}} #Required | |
vercel-project-id: ${{ env.VERCEL_PROJECT_UNPRICE_ID}} #Required | |
working-directory: ./ | |
vercel-args: '--env "VERCEL=true" --env "NODE_ENV=development" --env "VERCEL_ENV=preview" --env "DATABASE_URL=${{ steps.create-branch.outputs.db_url_with_pooler }}" --env "NEXT_PUBLIC_APP_DOMAIN=pr-${{ github.event.number }}-unprice.vercel.app" --build-env "NODE_ENV=development" --build-env "VERCEL=true" --build-env "VERCEL_ENV=preview" --build-env "DATABASE_URL=${{ steps.create-branch.outputs.db_url_with_pooler }}" --build-env "NEXT_PUBLIC_APP_DOMAIN=pr-${{ github.event.number }}-unprice.vercel.app"' | |
alias-domains: | | |
pr-${{ github.event.number }}-unprice.vercel.app | |
app-pr-${{ github.event.number }}-unprice.vercel.app | |
api-pr-${{ github.event.number }}-unprice.vercel.app | |
- name: Delete Secret | |
if: always() | |
run: | | |
rm -rf .env || true |