feat: GH actions #6
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: Pull Request Database Branch | |
on: [pull_request] | |
env: | |
NEON_DATABASE_USERNAME: ${{ secrets.NEON_DATABASE_USERNAME }} | |
NEON_API_KEY: ${{ secrets.NEON_API_KEY }} | |
NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} | |
UPLOADTHING_APP_ID: ${{ secrets.UPLOADTHING_APP_ID }} | |
UPLOADTHING_SECRET: ${{ secrets.UPLOADTHING_SECRET }} | |
AUTH_GITHUB_ID: ${{ secrets.AUTH_GITHUB_ID }} | |
AUTH_GITHUB_SECRET: ${{ secrets.AUTH_GITHUB_SECRET }} | |
AUTH_GOOGLE_ID: ${{ secrets.AUTH_GOOGLE_ID }} | |
AUTH_GOOGLE_SECRET: ${{ secrets.AUTH_GOOGLE_SECRET }} | |
AUTH_GOOGLE_CODE_VERIFIER: ${{ secrets.AUTH_GOOGLE_CODE_VERIFIER }} | |
jobs: | |
create-db-branch: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: pr-${{ github.event.number }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install | |
- 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@v4 | |
with: | |
project_id: ${{ env.NEON_PROJECT_ID }} | |
branch_name: pr-${{ github.event.number}}-${{ steps.branch_name.outputs.current_branch }} | |
username: ${{ env.NEON_DATABASE_USERNAME }} | |
api_key: ${{ env.NEON_API_KEY }} | |
- name: Run schema migrations | |
run: | | |
touch ./packages/db/.env | |
echo DATABASE_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require >> .env | |
pnpm turbo db:migrate | |
- name: Comment on Pull Request | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
message: | | |
Neon branch :elephant: : https://console.neon.tech/app/projects/${{ secrets.NEON_PROJECT_ID }}/branches/${{ steps.create-branch.outputs.branch_id }} |