Skip to content

Commit

Permalink
add workflows for preview deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
yujonglee committed Oct 20, 2024
1 parent 8ca8a69 commit f5386c7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/preview_core.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# https://github.com/neondatabase/preview-branches-with-fly
on: [pull_request]
env:
NEON_PROJECT_ID: ${{ vars.NEON_PROJECT_ID }}
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
jobs:
preview:
runs-on: ubuntu-latest
concurrency:
group: pr-${{ github.event.number }}
steps:
- uses: actions/checkout@v4
- id: branch-name
uses: tj-actions/branch-names@v8
- id: create-branch
uses: neondatabase/create-branch-action@v5
with:
project_id: ${{ env.NEON_PROJECT_ID }}
username: canary_prod_owner
database: canary_prod
branch_name: preview/${{ steps.branch-name.outputs.current_branch }}
api_key: ${{ secrets.NEON_API_KEY }}
- run: |
echo "DATABASE_URL=${{ steps.create-branch.outputs.db_url_with_pooler }}" >> "$GITHUB_ENV"
- id: deploy
uses: superfly/fly-pr-review-apps@1.2.1
with:
secrets: DATABASE_URL=$DATABASE_URL
- uses: thollander/actions-comment-pull-request@v2
with:
message: |-
Fly Preview URL :balloon: : ${{ steps.deploy.outputs.url }}
Neon branch :elephant: : https://console.neon.tech/app/projects/${{ env.NEON_PROJECT_ID }}/branches/${{ steps.create-branch.outputs.branch_id }}
16 changes: 16 additions & 0 deletions .github/workflows/preview_core_cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# https://github.com/neondatabase/preview-branches-with-fly
on:
pull_request:
types: [closed]
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- uses: superfly/fly-pr-review-apps@1.2.0
- uses: neondatabase/delete-branch-action@v3.1.3
with:
project_id: ${{ var.NEON_PROJECT_ID }}
branch: preview/${{ github.event.pull_request.head.ref }}
api_key: ${{ secrets.NEON_API_KEY }}

0 comments on commit f5386c7

Please sign in to comment.