diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 0000000..156ff68 --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "flutter-gakkai-07" + } +} \ No newline at end of file diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json new file mode 100644 index 0000000..253b612 --- /dev/null +++ b/.fvm/fvm_config.json @@ -0,0 +1,4 @@ +{ + "flutterSdkVersion": "3.27.1", + "flavors": {} +} \ No newline at end of file diff --git a/.github/.gitkeep b/.github/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/backend-cd.yaml b/.github/workflows/backend-cd.yaml new file mode 100644 index 0000000..0960563 --- /dev/null +++ b/.github/workflows/backend-cd.yaml @@ -0,0 +1,66 @@ +name: CD for Cloud Run Functions on Firebase + +on: + push: + branches: + - main + paths: + - "genkit/**" + +jobs: + changes: + name: Detect Changes + runs-on: ubuntu-latest + permissions: + pull-requests: read + contents: read + timeout-minutes: 15 + outputs: + genkit_functions: ${{ steps.filter.outputs.genkit_functions }} + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Detect changes + uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + genkit_functions: + - 'genkit/**' + + deploy_functions: + name: Deploy Cloud Run Functions + needs: + - changes + if: ${{ needs.changes.outputs.genkit_functions == 'true' }} + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + timeout-minutes: 60 + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: "Authenticate to Google Cloud" + uses: "google-github-actions/auth@v2" + with: + workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ secrets.SERVICE_ACCOUNT_MAIL }} + create_credentials_file: true + export_environment_variables: true + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + + - name: Install Dependencies + working-directory: ./genkit + run: npm install + + - name: Deploy to Functions + run: | + npm install -g firebase-tools + firebase deploy --only functions --force --project=${{ secrets.PROJECT_ID }} diff --git a/.github/workflows/backend-ci.yaml b/.github/workflows/backend-ci.yaml new file mode 100644 index 0000000..25490fc --- /dev/null +++ b/.github/workflows/backend-ci.yaml @@ -0,0 +1,58 @@ +name: CI for Cloud Run Functions on Firebase + +on: + pull_request: + paths: + - "genkit/**" + types: + - opened + - synchronize + +jobs: + changes: + name: Detect Changes + runs-on: ubuntu-latest + permissions: + pull-requests: read + contents: read + timeout-minutes: 15 + outputs: + genkit_functions: ${{ steps.filter.outputs.genkit_functions }} + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Detect changes + uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + genkit_functions: + - 'genkit/**' + + functions_ci: + name: Cloud Run Functions CI + needs: + - changes + if: ${{ needs.changes.outputs.genkit_functions == 'true' }} + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + timeout-minutes: 15 + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + + - name: Install Dependencies + working-directory: ./genkit + run: npm install + + - name: Check for linting errors + working-directory: ./genkit + run: npm run lint diff --git a/.github/workflows/frontend-cd.yaml b/.github/workflows/frontend-cd.yaml new file mode 100644 index 0000000..60e50f2 --- /dev/null +++ b/.github/workflows/frontend-cd.yaml @@ -0,0 +1,61 @@ +name: Deploy to Firebase Hosting on merge + +on: + workflow_dispatch: + push: + branches: + - main + paths-ignore: + - "genkit/**" + +jobs: + build_and_deploy: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + timeout-minutes: 15 + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Read Flutter SDK version + run: echo "FLUTTER_VERSION=$(jq -r '.flutterSdkVersion' .fvm/fvm_config.json)" >> $GITHUB_ENV + shell: bash + + - name: Create Firebase options file + run: | + cat < ./lib/firebase_options.dart + ${{ secrets.FIREBASE_CONFIG }} + EOF + + - name: Create dot_env file + run: | + cat < ./.env + ${{ secrets.DOT_ENV }} + EOF + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ env.FLUTTER_VERSION }} + + - name: flutter pub get + run: flutter pub get + + - name: flutter build web + run: flutter build web + + - name: "Authenticate to Google Cloud" + uses: "google-github-actions/auth@v2" + with: + workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ secrets.SERVICE_ACCOUNT_MAIL }} + create_credentials_file: true + export_environment_variables: true + + - name: Deploy to Firebase Hosting + run: | + npm install -g firebase-tools + firebase deploy --only hosting --project=${{ secrets.PROJECT_ID }} diff --git a/.github/workflows/frontend-ci.yaml b/.github/workflows/frontend-ci.yaml new file mode 100644 index 0000000..9a69076 --- /dev/null +++ b/.github/workflows/frontend-ci.yaml @@ -0,0 +1,60 @@ +name: Preview Deploy to Firebase Hosting on merge + +on: + pull_request: + types: + - opened + - synchronize + paths-ignore: + - "genkit/**" +jobs: + build_and_deploy: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + timeout-minutes: 15 + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Read Flutter SDK version + run: echo "FLUTTER_VERSION=$(jq -r '.flutterSdkVersion' .fvm/fvm_config.json)" >> $GITHUB_ENV + shell: bash + + - name: Create Firebase options file + run: | + cat < ./lib/firebase_options.dart + ${{ secrets.FIREBASE_CONFIG }} + EOF + + - name: Create dot_env file + run: | + cat < ./.env + ${{ secrets.DOT_ENV }} + EOF + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ env.FLUTTER_VERSION }} + + - name: flutter pub get + run: flutter pub get + + - name: flutter build web + run: flutter build web + + - name: "Authenticate to Google Cloud" + uses: "google-github-actions/auth@v2" + with: + workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} + service_account: ${{ secrets.SERVICE_ACCOUNT_MAIL }} + create_credentials_file: true + export_environment_variables: true + + - name: Preview Deploy to Firebase Hosting + run: | + npm install -g firebase-tools + firebase hosting:channel:deploy preview --project=${{ secrets.PROJECT_ID }} diff --git a/.gitignore b/.gitignore index 0665377..7dd86f4 100644 --- a/.gitignore +++ b/.gitignore @@ -47,10 +47,7 @@ app.*.map.json # tools .vscode .env -.firebaserc -firebase.json lib/firebase_options.dart genkit/node_modules -genkit/.firebaserc genkit/.genkit genkit/lib diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..130e23f --- /dev/null +++ b/firebase.json @@ -0,0 +1,54 @@ +{ + "flutter": { + "platforms": { + "dart": { + "lib/firebase_options.dart": { + "projectId": "flutter-gakkai-07", + "configurations": { + "web": "1:463090427578:web:7f5a01f865f5c3a6efc483" + } + } + } + } + }, + "functions": [ + { + "source": "genkit", + "codebase": "default", + "ignore": [ + "node_modules", + ".git", + "firebase-debug.log", + "firebase-debug.*.log", + "*.local" + ], + "predeploy": [ + "npm --prefix \"$RESOURCE_DIR\" run lint", + "npm --prefix \"$RESOURCE_DIR\" run build" + ] + } + ], + "emulators": { + "auth": { + "port": 9099 + }, + "functions": { + "port": 5001 + }, + "firestore": { + "port": 8080 + }, + "ui": { + "enabled": true + }, + "singleProjectMode": true + }, + "hosting": { + "public": "build/web", + "ignore": [ + "firebase.json", + "**/.* !**/.env", + "**/node_modules/**" + ] + } + } \ No newline at end of file diff --git a/genkit/.firebaserc b/genkit/.firebaserc new file mode 100644 index 0000000..156ff68 --- /dev/null +++ b/genkit/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "flutter-gakkai-07" + } +} \ No newline at end of file diff --git a/genkit/prompts/characterImageGenerator.prompt b/genkit/prompts/characterImageGenerator.prompt index 9ef55dd..2e5d0fd 100644 --- a/genkit/prompts/characterImageGenerator.prompt +++ b/genkit/prompts/characterImageGenerator.prompt @@ -3,6 +3,7 @@ model: vertexai/imagen3 config: temperature: 0.7 sampleCount: 1 + safetySettings: BLOCK_NONE input: schema: characterName: string