test preview #19
Workflow file for this run
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 | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
on: [pull_request] | |
jobs: | |
deploy-preview: | |
permissions: write-all | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
run_install: false | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install dependencies | |
run: pnpm install | |
- name: Get PR number | |
id: get_pull_request_sha | |
run: | | |
pull_request_sha=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH" | cut -c1-8) | |
echo "pull_request_sha=${pull_request_sha}" >> $GITHUB_OUTPUT | |
echo $pull_request_sha | |
- name: Neon Database Create Branch Action | |
uses: neondatabase/create-branch-action@v3 | |
id: create_branch | |
with: | |
project_id: ${{ secrets.NEON_PROJECT_ID }} | |
branch_name: ${{steps.get_pull_request_sha.outputs.pull_request_sha}} | |
api_key: ${{ secrets.NEON_API_KEY }} | |
username: ${{ secrets.PG_USERNAME }} | |
password: ${{ secrets.PG_PASSWORD }} | |
- name: Run Prisma Migrate | |
run: | | |
touch .env | |
echo DATABASE_URL=${{ steps.create_branch.outputs.db_url_with_pooler}}/neondb >> .env | |
echo DIRECT_DATABASE_URL=${{ steps.create_branch.outputs.db_url}}/neondb >> .env | |
pnpm dlx prisma generate | |
pnpm dlx prisma migrate deploy | |
- name: Install Vercel CLI | |
run: pnpm i --global vercel@latest | |
- name: Pull Vercel Environment Information | |
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Build Project Artifacts | |
run: vercel build --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Deploy Preview to Vercel | |
id: deploy | |
run: echo preview_url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}) >> $GITHUB_OUTPUT | |
- name: Comment on Pull Request | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
message: | | |
Vercel Preview URL :rocket: : ${{ steps.deploy.outputs.preview_url }} | |
Neon branch :elephant: : https://console.neon.tech/app/projects/${{ secrets.NEON_PROJECT_ID }}/branches/${{ steps.create_branch.outputs.branch_id }} |