From 22c0e76d82a740a5fc62af819ab2e345d2c408f5 Mon Sep 17 00:00:00 2001 From: cobo <39579511+nzmgfdprs@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:51:25 +0900 Subject: [PATCH 1/9] chore: .gitignore --- .firebaserc | 5 +++++ .gitignore | 3 --- firebase.json | 54 ++++++++++++++++++++++++++++++++++++++++++++++ genkit/.firebaserc | 5 +++++ 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 .firebaserc create mode 100644 firebase.json create mode 100644 genkit/.firebaserc 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/.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 From f0f1823cffd54fce651fb5ab1357e91fadd4cdd9 Mon Sep 17 00:00:00 2001 From: cobo <39579511+nzmgfdprs@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:55:55 +0900 Subject: [PATCH 2/9] chore: add .gitkeep --- .github/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/.gitkeep diff --git a/.github/.gitkeep b/.github/.gitkeep new file mode 100644 index 0000000..e69de29 From aaaa58999947f13358c3a672ded96bc8ba782047 Mon Sep 17 00:00:00 2001 From: cobo <39579511+nzmgfdprs@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:56:28 +0900 Subject: [PATCH 3/9] feat: backend-ci workflow --- .github/workflows/backend-ci.yaml | 58 +++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/backend-ci.yaml 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 From 0b211693e2e27d51a96156b27f4aa65f4e8478c3 Mon Sep 17 00:00:00 2001 From: cobo <39579511+nzmgfdprs@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:56:33 +0900 Subject: [PATCH 4/9] feat: backend-cd workflow --- .github/workflows/backend-cd.yaml | 66 +++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/backend-cd.yaml 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 }} From 0527eb515599dad1fd2ecaf91b8ef7aeb8fb6e16 Mon Sep 17 00:00:00 2001 From: cobo <39579511+nzmgfdprs@users.noreply.github.com> Date: Mon, 13 Jan 2025 22:05:33 +0900 Subject: [PATCH 5/9] feat: implements flutter ci/cd --- .fvm/fvm_config.json | 4 ++ .github/workflows/frontend-cd.yaml | 59 ++++++++++++++++++++++++++++++ .github/workflows/frontend-ci.yaml | 58 +++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 .fvm/fvm_config.json create mode 100644 .github/workflows/frontend-cd.yaml create mode 100644 .github/workflows/frontend-ci.yaml 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/workflows/frontend-cd.yaml b/.github/workflows/frontend-cd.yaml new file mode 100644 index 0000000..90a3c60 --- /dev/null +++ b/.github/workflows/frontend-cd.yaml @@ -0,0 +1,59 @@ +name: Deploy to Firebase Hosting on merge + +on: + workflow_dispatch: + push: + branches: + - main + +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..6f52988 --- /dev/null +++ b/.github/workflows/frontend-ci.yaml @@ -0,0 +1,58 @@ +name: Preview Deploy to Firebase Hosting on merge + +on: + pull_request: + types: + - opened + - synchronize +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 }} From eff23c1546e88c63a293b62f63160a37f11a2967 Mon Sep 17 00:00:00 2001 From: cobo <39579511+nzmgfdprs@users.noreply.github.com> Date: Mon, 13 Jan 2025 22:06:16 +0900 Subject: [PATCH 6/9] fix: Specify the number of output images for imagen --- genkit/prompts/characterTranslationEn.prompt | 1 + 1 file changed, 1 insertion(+) diff --git a/genkit/prompts/characterTranslationEn.prompt b/genkit/prompts/characterTranslationEn.prompt index e30e86f..4d128c5 100644 --- a/genkit/prompts/characterTranslationEn.prompt +++ b/genkit/prompts/characterTranslationEn.prompt @@ -2,6 +2,7 @@ model: googleai/gemini-2.0-flash-exp config: temperature: 1.0 + sampleCount: 1 input: schema: characterName: string From 33d7e612bdbadee3c899d0d043e3b1846c70eaa8 Mon Sep 17 00:00:00 2001 From: cobo <39579511+nzmgfdprs@users.noreply.github.com> Date: Mon, 13 Jan 2025 22:07:42 +0900 Subject: [PATCH 7/9] fix: Error in correction file --- genkit/prompts/characterTranslationEn.prompt | 1 - 1 file changed, 1 deletion(-) diff --git a/genkit/prompts/characterTranslationEn.prompt b/genkit/prompts/characterTranslationEn.prompt index 4d128c5..e30e86f 100644 --- a/genkit/prompts/characterTranslationEn.prompt +++ b/genkit/prompts/characterTranslationEn.prompt @@ -2,7 +2,6 @@ model: googleai/gemini-2.0-flash-exp config: temperature: 1.0 - sampleCount: 1 input: schema: characterName: string From cbc3f2bfb1b15500fd80984c04de3fcaf2bfdd8c Mon Sep 17 00:00:00 2001 From: cobo <39579511+nzmgfdprs@users.noreply.github.com> Date: Mon, 13 Jan 2025 22:45:10 +0900 Subject: [PATCH 8/9] chore: safety setting --- genkit/prompts/characterImageGenerator.prompt | 1 + 1 file changed, 1 insertion(+) 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 From f13f862a7767c209f59b1ab334ebcead86e4ccfe Mon Sep 17 00:00:00 2001 From: cobo <39579511+nzmgfdprs@users.noreply.github.com> Date: Mon, 13 Jan 2025 22:51:01 +0900 Subject: [PATCH 9/9] chore: settings paths-ignore --- .github/workflows/frontend-cd.yaml | 2 ++ .github/workflows/frontend-ci.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/frontend-cd.yaml b/.github/workflows/frontend-cd.yaml index 90a3c60..60e50f2 100644 --- a/.github/workflows/frontend-cd.yaml +++ b/.github/workflows/frontend-cd.yaml @@ -5,6 +5,8 @@ on: push: branches: - main + paths-ignore: + - "genkit/**" jobs: build_and_deploy: diff --git a/.github/workflows/frontend-ci.yaml b/.github/workflows/frontend-ci.yaml index 6f52988..9a69076 100644 --- a/.github/workflows/frontend-ci.yaml +++ b/.github/workflows/frontend-ci.yaml @@ -5,6 +5,8 @@ on: types: - opened - synchronize + paths-ignore: + - "genkit/**" jobs: build_and_deploy: runs-on: ubuntu-latest