Update neon_workflow.yml #1
This file contains hidden or 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 Vial MCP to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| - closed | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| jobs: | |
| setup: | |
| name: Setup | |
| outputs: | |
| branch: ${{ steps.branch_name.outputs.current_branch }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get branch name | |
| id: branch_name | |
| uses: tj-actions/branch-names@v8 | |
| create_neon_branch: | |
| name: Create Neon Branch | |
| outputs: | |
| db_url: ${{ steps.create_neon_branch.outputs.db_url }} | |
| db_url_with_pooler: ${{ steps.create_neon_branch.outputs.db_url_with_pooler }} | |
| needs: setup | |
| if: | | |
| github.event_name == 'pull_request' && ( | |
| github.event.action == 'synchronize' || | |
| github.event.action == 'opened' || | |
| github.event.action == 'reopened') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Create Neon Branch | |
| id: create_neon_branch | |
| uses: neondatabase/create-branch-action@v5 | |
| with: | |
| project_id: ${{ vars.NEON_PROJECT_ID }} | |
| branch_name: preview/pr-${{ github.event.number }}-${{ needs.setup.outputs.branch }} | |
| api_key: ${{ secrets.NEON_API_KEY }} | |
| - name: Run Migrations | |
| run: | | |
| psql -d "${{ steps.create_neon_branch.outputs.db_url_with_pooler }}" -f vial2/mcp/api/database/schema.sql | |
| env: | |
| DATABASE_URL: "${{ steps.create_neon_branch.outputs.db_url_with_pooler }}" | |
| - name: Post Schema Diff Comment to PR | |
| uses: neondatabase/schema-diff-action@v1 | |
| with: | |
| project_id: ${{ vars.NEON_PROJECT_ID }} | |
| compare_branch: preview/pr-${{ github.event.number }}-${{ needs.setup.outputs.branch }} | |
| api_key: ${{ secrets.NEON_API_KEY }} | |
| - name: Deploy to GitHub Pages Preview | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: . | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| with: | |
| preview: true | |
| delete_neon_branch: | |
| name: Delete Neon Branch | |
| needs: setup | |
| if: github.event_name == 'pull_request' && github.event.action == 'closed' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - name: Delete Neon Branch | |
| uses: neondatabase/delete-branch-action@v3 | |
| with: | |
| project_id: ${{ vars.NEON_PROJECT_ID }} | |
| branch: preview/pr-${{ github.event.number }}-${{ needs.setup.outputs.branch }} | |
| api_key: ${{ secrets.NEON_API_KEY }} | |
| - name: Comment PR with Cleanup Confirmation | |
| uses: actions/github-script@v6 | |
| with: | |
| script: | | |
| github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: `Neon branch preview/pr-${{ github.event.number }}-${{ needs.setup.outputs.branch }} deleted` | |
| }) |