add action to create PR-specific apps #35
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: Fly Deploy Disctictr V2 PR | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize, closed] | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_ORG_TOTKEN }} | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
FLY_REGION: "iad" | |
FLY_ORG: "mggg" | |
jobs: | |
staging_app: | |
runs-on: ubuntu-latest | |
concurrency: | |
group: pr-${{ github.event.number }} | |
environment: | |
name: pr-${{ github.event.number }} | |
url: ${{ steps.deploy-app.outputs.url }} | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: superfly/flyctl-actions/setup-flyctl@master | |
# fork new db from existing db | |
- name: Fork From DB | |
id: fork-db | |
run: | | |
flyctl postgres create \ | |
--name pr-${{ github.event.number }}-db \ | |
--region ewr \ | |
--initial-cluster-size 1 \ | |
--vm-size shared-cpu-2x \ | |
--org mggg \ | |
--fork-from districtr-v2-db | |
echo "::set-output name=name::pr-${{ github.event.number }}-db" | |
echo "::set-output password::$(flyctl postgres credentials pr-${{ github.event.number }}-db | grep Password | awk '{print $2}')" | |
# create copies of the app and api | |
- name: Deploy API | |
id: deploy-api | |
uses: superfly/[email protected] | |
with: | |
name: pr-${{ github.event.number }}-api | |
path: backend | |
postgres: ${{ steps.fork-db.outputs.name }} | |
env: | |
POSTGRES_SCHEME: "postgresql+psycopg" | |
POSTGRES_SERVER: "${{ steps.fork-db.outputs.name }}.flycast" | |
POSTGRES_USER: "postgres" | |
POSTGRES_PASSWORD: ${{ steps.fork-db.outputs.password }} | |
POSTGRES_DB: "postgres" | |
DATABASE_URL: "postgres://postgres:${{steps.fork-db.outputs.password}}@${{ steps.fork-db.outputs.name }}:5432/postgres" | |
- name: Deploy App | |
id: deploy-app | |
uses: superfly/[email protected] | |
with: | |
name: pr-${{ github.event.number }}-app | |
path: app | |