add action to create PR-specific apps #34
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" | |
# 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 }} | |
- name: Deploy App | |
id: deploy-app | |
uses: superfly/[email protected] | |
with: | |
name: pr-${{ github.event.number }}-app | |
path: app | |