Skip to content

Commit

Permalink
Merge pull request #2 from nozomi-koborinai/feature/add-workflows
Browse files Browse the repository at this point in the history
Feature/add workflows
  • Loading branch information
nozomi-koborinai authored Jan 13, 2025
2 parents a881265 + f13f862 commit d375035
Show file tree
Hide file tree
Showing 11 changed files with 314 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "flutter-gakkai-07"
}
}
4 changes: 4 additions & 0 deletions .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"flutterSdkVersion": "3.27.1",
"flavors": {}
}
Empty file added .github/.gitkeep
Empty file.
66 changes: 66 additions & 0 deletions .github/workflows/backend-cd.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
58 changes: 58 additions & 0 deletions .github/workflows/backend-ci.yaml
Original file line number Diff line number Diff line change
@@ -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
61 changes: 61 additions & 0 deletions .github/workflows/frontend-cd.yaml
Original file line number Diff line number Diff line change
@@ -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 <<EOF > ./lib/firebase_options.dart
${{ secrets.FIREBASE_CONFIG }}
EOF
- name: Create dot_env file
run: |
cat <<EOF > ./.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 }}
60 changes: 60 additions & 0 deletions .github/workflows/frontend-ci.yaml
Original file line number Diff line number Diff line change
@@ -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 <<EOF > ./lib/firebase_options.dart
${{ secrets.FIREBASE_CONFIG }}
EOF
- name: Create dot_env file
run: |
cat <<EOF > ./.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 }}
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
54 changes: 54 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -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/**"
]
}
}
5 changes: 5 additions & 0 deletions genkit/.firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "flutter-gakkai-07"
}
}
1 change: 1 addition & 0 deletions genkit/prompts/characterImageGenerator.prompt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ model: vertexai/imagen3
config:
temperature: 0.7
sampleCount: 1
safetySettings: BLOCK_NONE
input:
schema:
characterName: string
Expand Down

0 comments on commit d375035

Please sign in to comment.