Skip to content

Commit

Permalink
chore: updated github workflows (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldziher authored Nov 30, 2023
2 parents dc84efe + 3c8a0a4 commit 2adfe05
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 104 deletions.
34 changes: 7 additions & 27 deletions .github/workflows/build.yaml → .github/actions/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,24 @@ name: 'Build'
on:
workflow_call:
inputs:
service:
required: true
type: string
file_path:
required: true
type: string
timeout:
required: false
type: number
default: 5
gcp_oidc_provider_name:
required: false
type: string
default: github-provider
gcp_project_id:
required: false
type: string
default: basemind-ai-development
gcp_project_number:
required: false
type: string
default: 78794879644
gcp_service_account_name:
required: false
service:
required: true
type: string
default: github-actions
gcp_workload_identity_pool:
required: false
file_path:
required: true
type: string
default: dev-pool
gcp_region:
required: false
environment:
required: true
type: string
default: europe-west3
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout }}
environment: ${{ inputs.environment }}
permissions:
contents: 'read'
id-token: 'write'
Expand Down
79 changes: 79 additions & 0 deletions .github/actions/deploy_firebase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: 'Firebase Deployment'
on:
workflow_call:
inputs:
timeout:
required: false
type: number
default: 5
environment:
required: true
type: string
is_preview:
required: true
type: boolean
env:
FIREBASE_CLI_EXPERIMENTS: webframeworks
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: ${{ inputs.timeout }}
environment: ${{ inputs.environment }}
permissions:
checks: write
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Firebase CLI
run: npm install -g firebase-tools
- name: Install PNPM
uses: pnpm/[email protected]
id: pnpm-install
with:
version: 8
run_install: false
- name: Setup PNPM Cache
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Load Cached Dependencies
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Node dependencies
run: pnpm install -r
- name: Create .env File
shell: bash
run: |
echo "NEXT_PUBLIC_FIREBASE_API_KEY=${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}" >> frontend/.env
echo "NEXT_PUBLIC_FIREBASE_APP_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }}" >> frontend/.env
echo "NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}" >> frontend/.env
echo "NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }}" >> frontend/.env
echo "NEXT_PUBLIC_FIREBASE_MESSAGE_SENDER_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGE_SENDER_ID }}" >> frontend/.env
echo "NEXT_PUBLIC_FIREBASE_PROJECT_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }}" >> frontend/.env
echo "NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }}" >> frontend/.env
echo "NEXT_PUBLIC_SEGMENT_WRITE_KEY=${{ secrets.NEXT_PUBLIC_SEGMENT_WRITE_KEY }}" >> frontend/.env
echo "NEXT_PUBLIC_BACKEND_BASE_URL=${{ env.DEVELOPMENT_DASHBOARD_BACKEND_URL }}" >> frontend/.env
- uses: FirebaseExtended/action-hosting-deploy@v0
if: ${{ inputs.is_preview == false }}
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
projectId: ${{ env.GCP_PROJECT_I }}
channelId: live
- uses: FirebaseExtended/action-hosting-deploy@v0
if: ${{ inputs.is_preview == true }}
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
projectId: ${{ env.GCP_PROJECT_I }}
7 changes: 5 additions & 2 deletions .github/workflows/build-api-gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: 'Build (API-Gateway)'
on:
push:
branches:
- main
- development
- production
paths:
- 'gen/go/ptesting/**'
- 'gen/go/gateway/**'
Expand All @@ -11,7 +12,9 @@ on:
- 'shared/go/**'
jobs:
build:
uses: ./.github/workflows/build.yaml
uses: ./.github/actions/build.yaml
secrets: inherit
with:
file_path: ./docker/Dockerfile.go-services
service: api-gateway
environment: ${{ github.ref_name }}
5 changes: 4 additions & 1 deletion .github/workflows/build-cohere-connector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ on:
- 'gen/ts/cohere/**'
- 'services/cohere-connector/**'
- 'shared/ts/**'
- 'package.json'
jobs:
build:
uses: ./.github/workflows/build.yaml
uses: ./.github/actions/build.yaml
secrets: inherit
with:
file_path: ./docker/Dockerfile.ts-services
service: cohere-connector
environment: ${{ github.ref_name }}
4 changes: 3 additions & 1 deletion .github/workflows/build-dashboard-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ on:
- 'shared/go/**'
jobs:
build:
uses: ./.github/workflows/build.yaml
uses: ./.github/actions/build.yaml
secrets: inherit
with:
file_path: ./docker/Dockerfile.go-services
service: dashboard-backend
environment: ${{ github.ref_name }}
8 changes: 6 additions & 2 deletions .github/workflows/build-openai-connector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ name: 'Build (OpenAI-Connector)'
on:
push:
branches:
- main
- development
- production
paths:
- 'gen/ts/openai/**'
- 'services/openai-connector/**'
- 'shared/ts/**'
- 'package.json'
jobs:
build:
uses: ./.github/workflows/build.yaml
uses: ./.github/actions/build.yaml
secrets: inherit
with:
file_path: ./docker/Dockerfile.ts-services
service: openai-connector
environment: ${{ github.ref_name }}
16 changes: 16 additions & 0 deletions .github/workflows/deploy-frontend-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Frontend Preview
on:
pull_request:
branches:
- main
paths:
- 'frontend/src/**'
- 'shared/ts/**'
- 'package.json'
jobs:
deploy:
uses: ./.github/actions/deploy_firebase.yaml
secrets: inherit
with:
environment: ${{ github.ref_name }}
is_preview: true
78 changes: 8 additions & 70 deletions .github/workflows/deploy-frontend.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,17 @@
name: Deploy (Frontend)
on:
pull_request:
branches:
- main
paths:
- 'frontend/src/**'
- 'shared/ts/**'
push:
branches:
- main
- development
- production
paths:
- 'frontend/src/**'
- 'shared/ts/**'
env:
FIREBASE_CLI_EXPERIMENTS: webframeworks

- 'package.json'
jobs:
deploy:
environment: development
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Firebase CLI
run: npm install -g firebase-tools
- name: Install PNPM
uses: pnpm/[email protected]
id: pnpm-install
with:
version: 8
run_install: false
- name: Setup PNPM Cache
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Load Cached Dependencies
uses: actions/cache@v3
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Node dependencies
run: pnpm install -r
- name: Create .env File
shell: bash
run: |
echo "NEXT_PUBLIC_FIREBASE_API_KEY=${{ secrets.NEXT_PUBLIC_FIREBASE_API_KEY }}" >> frontend/.env
echo "NEXT_PUBLIC_FIREBASE_APP_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_APP_ID }}" >> frontend/.env
echo "NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=${{ secrets.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN }}" >> frontend/.env
echo "NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID }}" >> frontend/.env
echo "NEXT_PUBLIC_FIREBASE_MESSAGE_SENDER_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_MESSAGE_SENDER_ID }}" >> frontend/.env
echo "NEXT_PUBLIC_FIREBASE_PROJECT_ID=${{ secrets.NEXT_PUBLIC_FIREBASE_PROJECT_ID }}" >> frontend/.env
echo "NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=${{ secrets.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET }}" >> frontend/.env
echo "NEXT_PUBLIC_SEGMENT_WRITE_KEY=${{ secrets.NEXT_PUBLIC_SEGMENT_WRITE_KEY }}" >> frontend/.env
echo "NEXT_PUBLIC_BACKEND_BASE_URL=${{ env.DEVELOPMENT_DASHBOARD_BACKEND_URL }}" >> frontend/.env
- uses: FirebaseExtended/action-hosting-deploy@v0
if: github.event_name != 'pull_request'
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_BASEMIND_AI_DEVELOPMENT }}
channelId: live
projectId: basemind-ai-development
- uses: FirebaseExtended/action-hosting-deploy@v0
if: github.event_name == 'pull_request'
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_BASEMIND_AI_DEVELOPMENT }}
projectId: basemind-ai-development
uses: ./.github/actions/deploy_firebase.yaml
secrets: inherit
with:
environment: ${{ github.ref_name }}
is_preview: false
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2adfe05

Please sign in to comment.