refactor(NP-87): Add Neon deployment workflows #1
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 Production | |
on: | |
push: | |
branches: | |
- 'main' | |
- 'develop' | |
workflow_dispatch: | |
pull_request: | |
jobs: | |
deploy-production: | |
permissions: write-all | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Get last commit SHA | |
id: get_sha | |
run: | | |
echo sha="${{ github.event.before }}" | cut -c1-8 >> $GITHUB_OUTPUT | |
- name: Search branch by name | |
id: get_branch_id | |
# list all branches and filter by name | |
run: | | |
branch_id=$(curl --silent \ | |
"https://console.neon.tech/api/v2/projects/${{ secrets.NEON_PROJECT_ID }}/branches" \ | |
--header "Accept: application/json" \ | |
--header "Content-Type: application/json" \ | |
--header "Authorization: Bearer ${{ secrets.NEON_API_KEY }}" \ | |
| jq -r .branches \ | |
| jq -c '.[] | select(.name | contains("'${{ steps.get_sha.outputs.sha }}'")) .id' \ | |
| jq -r \ | |
) \ | |
echo "branch_id=${branch_id}" >> $GITHUB_OUTPUT | |
# - name: Run Prisma Migrate | |
# run: | | |
# touch .env | |
# echo DATABASE_URL="${{ secrets.DATABASE_URL}}" >> .env | |
# echo DIRECT_DATABASE_URL="${{ secrets.DIRECT_DATABASE_URL}}" >> .env | |
# npx prisma migrate deploy | |
- name: Install Vercel CLI | |
run: npm install --global vercel@latest | |
# - name: Pull Vercel Environment Information | |
# run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} | |
# - name: Build Project Artifacts | |
# run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} | |
# - name: Deploy Project Artifacts to Vercel | |
# run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Deploy Production to Vercel | |
id: deploy | |
run: | | |
echo preview_url=$(vercel deploy --prod \ | |
--public --yes --token=${{ secrets.VERCEL_TOKEN }}) \ | |
>> $GITHUB_OUTPUT | |
- name: Delete Neon Branch | |
uses: neondatabase/delete-branch-action@v2 | |
with: | |
project_id: ${{ secrets.NEON_PROJECT_ID }} | |
branch_id: ${{ steps.get_branch_id.outputs.branch_id }} | |
api_key: ${{ secrets.NEON_API_KEY }} |