Skip to content

feat: first iteration of pr neon db branching #15

feat: first iteration of pr neon db branching

feat: first iteration of pr neon db branching #15

Workflow file for this run

name: CI
on:
push:
branches: ['main']
pull_request:
types: [opened, synchronize]
jobs:
create-neon-branch:
permissions: write-all
runs-on: ubuntu-latest
outputs:
database_url: ${{ steps.get-database-url.outputs.database_url }}
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v7
- name: Install neon cli
run: npm install -g neonctl
- name: Create a neon branch
id: create-branch
run: neonctl branches create --project-id ${{ secrets.NEON_PROJECT_ID }} --name ${{ steps.branch-name.outputs.current_branch }} --api-key ${{ secrets.NEON_API_KEY }} --compute --type read_write
- name: get Neon branch ID
id: get-neon-branch-id
run: |
echo branch_id=$(neonctl branches get ${{ steps.branch-name.outputs.current_branch }} --project-id ${{ secrets.NEON_PROJECT_ID }} --api-key ${{ secrets.NEON_API_KEY }} --output json | jq -r '.id') >> $GITHUB_OUTPUT
- name: Output the new database url
id: get-database-url
run: |
echo database_url=$(neonctl cs ${{ steps.branch-name.outputs.current_branch }} --project-id ${{ secrets.NEON_PROJECT_ID }} --role-name ${{ secrets.PG_USERNAME }} --database-name ${{ secrets.PG_DATABASE }} --api-key ${{ secrets.NEON_API_KEY }}) >> $GITHUB_OUTPUT
build:
name: CI
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- uses: pnpm/action-setup@v2
name: Install pnpm
with:
run_install: false
- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install
- name: Spell check
run: pnpm turbo lint:spell
- name: Lint Markdown
run: pnpm turbo lint:md
- name: Check Formatting
run: pnpm turbo format:check
- name: Lint
run: pnpm turbo lint
- name: Typecheck
run: pnpm turbo typecheck
- name: Build
env:
DATABASE_URL: ${{ needs.create-neon-branch.outputs.database_url }}
run: pnpm turbo build