-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into mobile-ui-rebase
- Loading branch information
Showing
56 changed files
with
1,862 additions
and
1,052 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
name: Fly Deploy Disctictr V2 Pull Request app | ||
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: "ewr" | ||
FLY_ORG: "mggg" | ||
jobs: | ||
pr_review_app: | ||
runs-on: ubuntu-latest | ||
|
||
concurrency: | ||
group: pr-${{ github.event.number }} | ||
|
||
environment: | ||
name: pr-${{ github.event.number }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: superfly/flyctl-actions/setup-flyctl@master | ||
|
||
- name: Set shared environment variables | ||
run: | | ||
echo "db_name=${{ github.event.repository.name }}-${{ github.event.number }}-db" >> $GITHUB_ENV | ||
echo "api_app_name=${{ github.event.repository.name }}-${{ github.event.number }}-api" >> $GITHUB_ENV | ||
echo "frontend_app_name=${{ github.event.repository.name }}-${{ github.event.number }}-app" >> $GITHUB_ENV | ||
- name: Destroy Resources | ||
if: github.event.action == 'closed' | ||
run: | | ||
app_name="${{ github.event.repository.name }}-${{ github.event.number }}-api" | ||
frontend_app_name="${{ github.event.repository.name }}-${{ github.event.number }}-app" | ||
db_name="${{ github.event.repository.name }}-${{ github.event.number }}-db" | ||
echo "Destroying app $app_name" | ||
flyctl apps destroy "$app_name" -y | ||
echo "Destroying frontend app $frontend_app_name" | ||
flyctl apps destroy "$frontend_app_name" -y | ||
echo "Destroying database $db_name" | ||
flyctl apps destroy "$db_name" -y | ||
echo "Resources for PR #${{ github.event.number }} have been destroyed." | ||
env: | ||
FLY_API_TOKEN: ${{ secrets.FLY_ORG_TOTKEN }} | ||
|
||
# fork new db from existing production db if it doesn't already exist | ||
# eventually we may want to maintain a stage and only fork that | ||
- name: Fork From DB | ||
id: fork-db | ||
if: github.event.action != 'closed' | ||
run: | | ||
if flyctl postgres list | grep -q ${{ github.event.repository.name }}-${{ github.event.number }}-db; then | ||
echo "DB already exists" | ||
else | ||
flyctl postgres create \ | ||
--name ${{ github.event.repository.name }}-${{ github.event.number }}-db \ | ||
--region ewr \ | ||
--initial-cluster-size 1 \ | ||
--vm-size shared-cpu-2x \ | ||
-p ${{ secrets.FLY_PR_PG_PASSWORD }} \ | ||
--org mggg \ | ||
--fork-from districtr-v2-db | ||
if [ $? -eq 0 ]; then | ||
echo "Database created successfully." | ||
else | ||
echo "Failed to create database." | ||
exit 1 | ||
fi | ||
fi | ||
echo "::set-output name=name::${{ github.event.repository.name }}-${{ github.event.number }}-db" | ||
# manually launch and deploy the api app | ||
- name: Launch API | ||
if: github.event.action != 'closed' | ||
run: | | ||
app="${{ github.event.repository.name }}-${{ github.event.number }}-api" | ||
db_name="${{ github.event.repository.name }}-${{ github.event.number }}-db" | ||
config="fly.toml" | ||
# Check if the app exists | ||
if flyctl apps list | grep -q "$app"; then | ||
echo "App $app already exists. Skipping launch." | ||
else | ||
flyctl launch \ | ||
--no-deploy --copy-config --name "$app" | ||
echo "App $app launched successfully." | ||
fi | ||
# Output app name for use in the deploy step | ||
echo "api_app_name=$app" >> $GITHUB_ENV | ||
working-directory: backend | ||
|
||
- name: Deploy API | ||
if: github.event.action != 'closed' | ||
run: | | ||
flyctl secrets set \ | ||
-a ${{ github.event.repository.name }}-${{ github.event.number }}-api \ | ||
POSTGRES_SCHEME="postgresql+psycopg" \ | ||
POSTGRES_SERVER="${{ github.event.repository.name }}-${{ github.event.number }}-db.flycast" \ | ||
POSTGRES_USER="postgres" \ | ||
POSTGRES_PASSWORD=${{ secrets.FLY_PR_PG_PASSWORD }} \ | ||
POSTGRES_DB="districtr_v2_api" \ | ||
BACKEND_CORS_ORIGINS="https://${{ github.event.repository.name }}-${{ github.event.number }}-app.fly.dev,https://districtr-v2-frontend.fly.dev" \ | ||
DATABASE_URL="postgresql://postgres:${{ secrets.FLY_PR_PG_PASSWORD }}@${{ steps.fork-db.outputs.name }}.flycast:5432/districtr_v2_api?sslmode=disable&options=-csearch_path%3Dpublic" | ||
flyctl deploy \ | ||
--config fly.toml --app "${{ github.event.repository.name }}-${{ github.event.number }}-api" \ | ||
--strategy immediate '--ha=false' --vm-cpu-kind shared --vm-cpus 1 --vm-memory 256 \ | ||
working-directory: backend | ||
|
||
- name: Check and Launch Frontend App | ||
id: launch | ||
if: github.event.action != 'closed' | ||
run: | | ||
app="${{ github.event.repository.name }}-${{ github.event.number }}-app" | ||
api_app="${{ github.event.repository.name }}-${{ github.event.number }}-api" | ||
config="fly.toml" | ||
# Check if the app exists | ||
if flyctl apps list | grep -q "$app"; then | ||
echo "App $app already exists. Skipping launch." | ||
else | ||
echo "Launching app $app." | ||
# Run the flyctl launch command | ||
flyctl launch \ | ||
--no-deploy --copy-config --name "${{ github.event.repository.name }}-${{ github.event.number }}-app" \ | ||
--build-arg NEXT_PUBLIC_API_URL="https://${{ github.event.repository.name }}-${{ github.event.number }}-api.fly.dev" \ | ||
--build-arg NEXT_PUBLIC_S3_BUCKET_URL=https://districtr-v2-dev.s3.amazonaws.com | ||
|
||
echo "App $app launched successfully." | ||
fi | ||
|
||
# Output app name for use in the deploy step | ||
echo "frontend_app_name=$app" >> $GITHUB_ENV | ||
working-directory: app | ||
|
||
- name: Deploy frontend | ||
if: github.event.action != 'closed' | ||
run: | | ||
app_name="${{ github.event.repository.name }}-${{ github.event.number }}-app" | ||
config="fly.toml" | ||
flyctl secrets set \ | ||
-a "${{ github.event.repository.name }}-${{ github.event.number }}-app" \ | ||
NEXT_PUBLIC_API_URL="https://${{ github.event.repository.name }}-${{ github.event.number }}-api.fly.dev" \ | ||
NEXT_PUBLIC_S3_BUCKET_URL=https://districtr-v2-dev.s3.amazonaws.com | ||
# Deploy the app | ||
flyctl deploy --config "$config" --app "${{ github.event.repository.name }}-${{ github.event.number }}-app" \ | ||
--build-arg NEXT_PUBLIC_API_URL="https://${{ github.event.repository.name }}-${{ github.event.number }}-api.fly.dev" \ | ||
--build-arg NEXT_PUBLIC_S3_BUCKET_URL=https://districtr-v2-dev.s3.amazonaws.com \ | ||
--strategy immediate '--ha=false' \ | ||
--vm-cpu-kind shared --vm-cpus 1 --vm-memory 256 | ||
working-directory: app |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
NEXT_PUBLIC_API_URL=http://localhost:8000 | ||
NEXT_PUBLIC_S3_BUCKET_URL=https://pub-fa71193941a74e14a38eee99f30f53d9.r2.dev | ||
NEXT_PUBLIC_S3_BUCKET_URL=https://districtr-v2-dev.s3.amazonaws.com |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
NEXT_PUBLIC_API_URL=http://localhost:8000 | ||
NEXT_PUBLIC_S3_BUCKET_URL=https://pub-fa71193941a74e14a38eee99f30f53d9.r2.dev | ||
NEXT_PUBLIC_S3_BUCKET_URL=https://districtr-v2-dev.s3.amazonaws.com |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
NEXT_PUBLIC_API_URL=https://districtr-v2-api.fly.dev | ||
NEXT_PUBLIC_S3_BUCKET_URL=https://pub-fa71193941a74e14a38eee99f30f53d9.r2.dev | ||
NEXT_PUBLIC_S3_BUCKET_URL=https://districtr-v2-dev.s3.amazonaws.com |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
...require('prettier-airbnb-config'), | ||
}; |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { NextResponse } from "next/server"; | ||
import {NextResponse} from 'next/server'; | ||
|
||
export const dynamic = "force-dynamic"; | ||
export const dynamic = 'force-dynamic'; | ||
|
||
// A faulty API route to test Sentry's error monitoring | ||
export function GET() { | ||
throw new Error("Sentry Example API Route Error"); | ||
return NextResponse.json({ data: "Testing Sentry Error..." }); | ||
throw new Error('Sentry Example API Route Error'); | ||
return NextResponse.json({data: 'Testing Sentry Error...'}); | ||
} |
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
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
Oops, something went wrong.