Skip to content

Commit

Permalink
Update to latest Platformatic Cloud (#52)
Browse files Browse the repository at this point in the history
* Update to latest Platformatic Cloud

Signed-off-by: Matteo Collina <[email protected]>

* fixup

Signed-off-by: Matteo Collina <[email protected]>

---------

Signed-off-by: Matteo Collina <[email protected]>
  • Loading branch information
mcollina authored Mar 27, 2023
1 parent 5edbf34 commit 22917a5
Show file tree
Hide file tree
Showing 6 changed files with 292 additions and 243 deletions.
34 changes: 6 additions & 28 deletions .github/workflows/platformatic-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Deploy Platformatic application to the cloud
on:
pull_request:
paths-ignore:
- 'docs/**'
- '**.md'
push:
branches:
- 'main'

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
Expand All @@ -20,33 +19,12 @@ jobs:
uses: actions/checkout@v3
- name: npm install --omit=dev
run: npm install --omit=dev
- name: Get PR number
id: get_pull_number
run: |
pull_sha=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH")
echo "pull_sha=${pull_sha}" >> $GITHUB_OUTPUT
echo $pull_sha
- uses: neondatabase/delete-branch-by-name-action@main
with:
project_id: ${{ secrets.NEON_PROJECT_ID }}
branch_name: ${{ steps.get_pull_number.outputs.pull_sha }}
api_key: ${{ secrets.NEON_API_KEY }}
- run: sleep 10
- uses: neondatabase/create-branch-action@v2
with:
project_id: ${{ secrets.NEON_PROJECT_ID }}
branch_name: ${{ steps.get_pull_number.outputs.pull_sha }}
api_key: ${{ secrets.NEON_API_KEY }}
username: ${{ secrets.DBUSER }}
Password: ${{ secrets.DBPASSWORD }}
id: create-branch
- name: Get DATABASE_URL
run: echo DATABASE_URL=${{ steps.create-branch.outputs.db_url}}/neondb
- name: Deploy project
uses: platformatic/onestep@latest
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
platformatic_api_key: ${{ secrets.PLATFORMATIC_API_KEY }}
platformatic_workspace_id: ${{ secrets.PLATFORMATIC_DYNAMIC_WORKSPACE_ID }}
platformatic_workspace_key: ${{ secrets.PLATFORMATIC_DYNAMIC_WORKSPACE_KEY }}
platformatic_config_path: ./platformatic.db.json
env:
PLT_SERVER_LOGGER_LEVEL: info
Expand All @@ -55,4 +33,4 @@ jobs:
PLT_ADMIN_SECRET: ${{ secrets.PLT_ADMIN_SECRET }}
PLT_LOCK: ${{ vars.PLT_LOCK }}
PLT_LEADER_POLL: ${{ vars.PLT_LEADER_POLL }}
DATABASE_URL: ${{ steps.create-branch.outputs.db_url}}/neondb
DATABASE_URL: ${{ secrets.NEON_DB_URL }}
59 changes: 59 additions & 0 deletions .github/workflows/platformatic-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Deploy Platformatic application to the cloud
on:
pull_request:
paths-ignore:
- 'docs/**'
- '**.md'

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
cancel-in-progress: true

jobs:
build_and_deploy:
runs-on: ubuntu-latest
environment:
name: development
steps:
- name: Checkout application project repository
uses: actions/checkout@v3
- name: npm install --omit=dev
run: npm install --omit=dev
- name: Get PR number
id: get_pull_number
run: |
pull_sha=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH")
echo "pull_sha=${pull_sha}" >> $GITHUB_OUTPUT
echo $pull_sha
- uses: neondatabase/delete-branch-by-name-action@main
with:
project_id: ${{ secrets.NEON_PROJECT_ID }}
branch_name: ${{ steps.get_pull_number.outputs.pull_sha }}
api_key: ${{ secrets.NEON_API_KEY }}
- run: sleep 10
- uses: neondatabase/create-branch-action@v2
with:
project_id: ${{ secrets.NEON_PROJECT_ID }}
branch_name: ${{ steps.get_pull_number.outputs.pull_sha }}
api_key: ${{ secrets.NEON_API_KEY }}
username: ${{ secrets.DBUSER }}
Password: ${{ secrets.DBPASSWORD }}
id: create-branch
- name: Get DATABASE_URL
run: echo DATABASE_URL=${{ steps.create-branch.outputs.db_url}}/neondb
- name: Deploy project
uses: platformatic/onestep@latest
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
platformatic_workspace_id: ${{ secrets.PLATFORMATIC_DYNAMIC_WORKSPACE_ID }}
platformatic_workspace_key: ${{ secrets.PLATFORMATIC_DYNAMIC_WORKSPACE_KEY }}
platformatic_config_path: ./platformatic.db.json
env:
PLT_SERVER_LOGGER_LEVEL: info
PORT: 3042
PLT_SERVER_HOSTNAME: 127.0.0.1
PLT_ADMIN_SECRET: ${{ secrets.PLT_ADMIN_SECRET }}
PLT_LOCK: ${{ vars.PLT_LOCK }}
PLT_LEADER_POLL: ${{ vars.PLT_LEADER_POLL }}
DATABASE_URL: ${{ steps.create-branch.outputs.db_url}}/neondb
Loading

0 comments on commit 22917a5

Please sign in to comment.