Update README #1
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: Preview Deployment | |
on: [pull_request] | |
env: | |
DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
COOKIE_SECRET: ${{ secrets.COOKIE_SECRET }} | |
INSTANT_POSTGRES_API_KEY: ${{ secrets.INSTANT_POSTGRES_API_KEY }} | |
CLOUDFLARE_TURNSTILE_SECRET_KEY: ${{ secrets.CLOUDFLARE_TURNSTILE_SECRET_KEY }} | |
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }} | |
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }} | |
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
GH_TOKEN: ${{ secrets.GH_TOKEN }} # Required for commenting on pull requests for private repos | |
VITE_CLOUDFLARE_TURNSTILE_SITE_KEY: ${{ secrets.VITE_CLOUDFLARE_TURNSTILE_SITE_KEY }} | |
NEON_API_KEY: ${{ secrets.NEON_API_KEY }} | |
jobs: | |
deploy-production: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
- name: Install Dependencies | |
run: bun install | |
- run: bun run turbo db:migrate | |
- name: Get git branch name | |
id: branch-name | |
uses: tj-actions/branch-names@v8 | |
- run: | | |
echo "VITE_API_URL=https://${{ steps.branch-name.outputs.current_branch }}.instant-postgres-api.pages.dev" >> "$GITHUB_ENV" | |
echo "APP_URL=https://${{ steps.branch-name.outputs.current_branch }}.instant-postgres.pages.dev" >> "$GITHUB_ENV" | |
- id: create-branch | |
uses: neondatabase/create-branch-action@v5 | |
with: | |
project_id: delicate-smoke-42060837 | |
username: "neondb_owner" # Change this to the role you use to connect to your database | |
# parent: dev # optional (defaults to your primary branch) | |
branch_name: preview/${{ steps.branch-name.outputs.current_branch }} | |
api_key: ${{ secrets.NEON_API_KEY }} # Generate an API key in your Neon account settings | |
- run: | | |
echo "DATABASE_URL=${{ steps.create-branch.outputs.db_url_with_pooler }}" >> "$GITHUB_ENV" | |
- run: bun run build --filter=api | |
- name: Deploy API | |
uses: AdrianGonz97/refined-cf-pages-action@v1 | |
with: | |
githubToken: ${{ secrets.GH_TOKEN }} | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: instant-postgres-api | |
directory: ./dist | |
workingDirectory: ./apps/api | |
deploymentName: ${{ steps.branch-name.outputs.current_branch }} | |
branch: ${{ steps.branch-name.outputs.current_branch }} | |
- run: bun run build --filter=web | |
- name: Deploy Web | |
uses: AdrianGonz97/refined-cf-pages-action@v1 | |
with: | |
githubToken: ${{ secrets.GH_TOKEN }} | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: instant-postgres | |
directory: ./build/client | |
workingDirectory: ./apps/web | |
deploymentName: ${{ steps.branch-name.outputs.current_branch }} | |
branch: ${{ steps.branch-name.outputs.current_branch }} |