Skip to content

Commit

Permalink
Deploy to prod-slack-altinndevops in prod resource group
Browse files Browse the repository at this point in the history
  • Loading branch information
bdb-dd committed Apr 19, 2024
1 parent 6a49f8d commit d4b9741
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 90 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Trigger auto deployment for assistants-slack-altinndevops

# When this action will be executed
on:
# Automatically trigger it when detected changes in repo
push:
branches:
[ main ]
paths:
- '**'
- '.github/workflows/assistants-slack-altinndevops-AutoDeployTrigger-b3f5dbde-b8af-4b5f-94e9-d2eb110abe37.yml'

# Allow manual trigger
workflow_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: prod-slack-altinndevops

steps:
- name: Checkout to the branch
uses: actions/checkout@v4

- name: Azure Login
uses: azure/login@v2
with:
creds: ${{ secrets.ASSISTANTSSLACKALTINNDEVOPS_AZURE_CREDENTIALS }}

- name: Build and push container image to registry
uses: azure/container-apps-deploy-action@v2
with:
appSourcePath: ${{ github.workspace }}
registryUrl: altinnaicontainers.azurecr.io
registryUsername: ${{ secrets.ASSISTANTSSLACKALTINNDEVOPS_REGISTRY_USERNAME }}
registryPassword: ${{ secrets.ASSISTANTSSLACKALTINNDEVOPS_REGISTRY_PASSWORD }}
containerAppName: assistants-slack-altinndevops
resourceGroup: assistants-prod-norwayeast
imageToBuild: altinnaicontainers.azurecr.io/assistants-slack-altinndevops:${{ github.sha }}
buildArguments: |
"VITE_SLACK_APP_SUPABASE_API_URL=${{ vars.SLACK_APP_SUPABASE_API_URL }}"
"VITE_SLACK_APP_SUPABASE_ANON_KEY=${{secrets.SLACK_APP_SUPABASE_ANON_KEY}}"
environmentVariables: >
"OPENAI_API_KEY=secretref:openai-api-key"
"AZURE_OPENAI_API_KEY=secretref:azure-openai-api-key"
"SLACK_APP_TOKEN=secretref:slack-app-token"
"SLACK_BOT_TOKEN=secretref:slack-bot-token"
"SLACK_BOT_SIGNING_SECRET=secretref:slack-bot-signing-secret"
"TYPESENSE_API_KEY=secretref:typesense-api-key"
"SLACK_APP_SUPABASE_API_URL=${{ vars.SLACK_APP_SUPABASE_API_URL }}"
"SLACK_APP_SUPABASE_ANON_KEY=${{ secrets.SLACK_APP_SUPABASE_ANON_KEY }}"
"USE_AZURE_OPENAI_API=${{ vars.USE_AZURE_OPENAI_API}}"
"OPENAI_API_URL=${{ vars.OPENAI_API_URL }}"
"OPENAI_API_MODEL_NAME=${{ vars.OPENAI_API_MODEL_NAME }}"
"AZURE_OPENAI_API_URL=${{ vars.AZURE_OPENAI_API_URL }}"
"AZURE_OPENAI_DEPLOYMENT=${{ vars.AZURE_OPENAI_DEPLOYMENT }}"
"AZURE_OPENAI_VERSION=${{ vars.AZURE_OPENAI_VERSION }}"
"COLBERT_API_URL=${{ vars.COLBERT_API_URL }}"
"TYPESENSE_API_HOST=${{ vars.TYPESENSE_API_HOST }}"
"TYPESENSE_DOCS_COLLECTION=${{ vars.TYPESENSE_DOCS_COLLECTION }}"
"TYPESENSE_DOCS_SEARCH_PHRASE_COLLECTION=${{ vars.TYPESENSE_DOCS_SEARCH_PHRASE_COLLECTION }}"
"MAX_CONTEXT_DOC_COUNT=${{ vars.MAX_CONTEXT_DOC_COUNT }}"
"MAX_CONTEXT_LENGTH=${{ vars.MAX_CONTEXT_LENGTH }}"
"MAX_SOURCE_LENGTH=${{ vars.MAX_SOURCE_LENGTH }}"
"DEBUG_SLACK=${{ vars.DEBUG_SLACK }}"
"DEBUG_INSTRUCTOR=${{ vars.DEBUG_INSTRUCTOR }}"
"LOG_LEVEL=${{ vars.LOG_LEVEL }}"

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Trigger auto deployment for digdir-assistants-altinn
name: prod-slack-altinn - Auto deploy

# When this action will be executed
on:
Expand All @@ -8,14 +8,15 @@ on:
[ release ]
paths:
- '**'
- '.github/workflows/digdir-assistants-altinn-AutoDeployTrigger-06da9e65-21d6-4cd0-803b-5776683d6cfc.yml'
- '.github/workflows/prod-slack-altinn-AutoDeployTrigger-06da9e65-21d6-4cd0-803b-5776683d6cfc.yml'

# Allow manual trigger
workflow_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: prod-slack-altinn

steps:
- name: Checkout to the branch
Expand All @@ -36,6 +37,7 @@ jobs:
containerAppName: digdir-assistants-altinn
resourceGroup: altinn-ai-assistant
imageToBuild: altinnaicontainers.azurecr.io/digdir-assistants-prod:${{ github.sha }}
environmentVariables: VITE_SLACK_APP_SUPABASE_API_URL=${{secrets.VITE_SLACK_APP_SUPABASE_API_URL}} VITE_SLACK_APP_SUPABASE_ANON_KEY=${{secrets.VITE_SLACK_APP_SUPABASE_ANON_KEY}}



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: test-slack-digdir - Auto deploy

# When this action will be executed
on:
# Automatically trigger it when detected changes in repo
push:
branches:
[ main ]
paths:
- '**'
- '.github/workflows/test-slack-digdir-AutoDeployTrigger-219d7bf4-be08-4d50-8074-9c2bc8dfba13.yml'

# Allow manual trigger
workflow_dispatch:

jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: test-slack-digdir

steps:
- name: Checkout to the branch
uses: actions/checkout@v4

- name: Azure Login
uses: azure/login@v2
with:
creds: ${{ secrets.DIGDIRASSISTANTSTEST_AZURE_CREDENTIALS }}

- name: Build and push container image to registry
uses: azure/container-apps-deploy-action@v2
with:
appSourcePath: ${{ github.workspace }}
registryUrl: altinnaicontainers.azurecr.io
registryUsername: ${{ secrets.DIGDIRASSISTANTSTEST_REGISTRY_USERNAME }}
registryPassword: ${{ secrets.DIGDIRASSISTANTSTEST_REGISTRY_PASSWORD }}
containerAppName: digdir-assistants-test
resourceGroup: altinn-ai-assistant
imageToBuild: altinnaicontainers.azurecr.io/digdir-assistants:${{ github.sha }}
buildArguments: |
"VITE_SLACK_APP_SUPABASE_API_URL=${{ vars.SLACK_APP_SUPABASE_API_URL }}"
"VITE_SLACK_APP_SUPABASE_ANON_KEY=${{secrets.SLACK_APP_SUPABASE_ANON_KEY}}"
environmentVariables: >
"OPENAI_API_KEY=secretref:openai-api-key"
"AZURE_OPENAI_API_KEY=secretref:azure-openai-api-key"
"SLACK_APP_TOKEN=secretref:slack-app-token"
"SLACK_BOT_TOKEN=secretref:slack-bot-token"
"SLACK_BOT_SIGNING_SECRET=secretref:slack-bot-signing-secret"
"TYPESENSE_API_KEY=secretref:typesense-api-key"
"SLACK_APP_SUPABASE_API_URL=${{ vars.SLACK_APP_SUPABASE_API_URL }}"
"SLACK_APP_SUPABASE_ANON_KEY=${{ secrets.SLACK_APP_SUPABASE_ANON_KEY }}"
"USE_AZURE_OPENAI_API=${{ vars.USE_AZURE_OPENAI_API}}"
"OPENAI_API_URL=${{ vars.OPENAI_API_URL }}"
"OPENAI_API_MODEL_NAME=${{ vars.OPENAI_API_MODEL_NAME }}"
"AZURE_OPENAI_API_URL=${{ vars.AZURE_OPENAI_API_URL }}"
"AZURE_OPENAI_DEPLOYMENT=${{ vars.AZURE_OPENAI_DEPLOYMENT }}"
"AZURE_OPENAI_VERSION=${{ vars.AZURE_OPENAI_VERSION }}"
"COLBERT_API_URL=${{ vars.COLBERT_API_URL }}"
"TYPESENSE_API_HOST=${{ vars.TYPESENSE_API_HOST }}"
"TYPESENSE_DOCS_COLLECTION=${{ vars.TYPESENSE_DOCS_COLLECTION }}"
"TYPESENSE_DOCS_SEARCH_PHRASE_COLLECTION=${{ vars.TYPESENSE_DOCS_SEARCH_PHRASE_COLLECTION }}"
"MAX_CONTEXT_DOC_COUNT=${{ vars.MAX_CONTEXT_DOC_COUNT }}"
"MAX_CONTEXT_LENGTH=${{ vars.MAX_CONTEXT_LENGTH }}"
"MAX_SOURCE_LENGTH=${{ vars.MAX_SOURCE_LENGTH }}"
"DEBUG_SLACK=${{ vars.DEBUG_SLACK }}"
"DEBUG_INSTRUCTOR=${{ vars.DEBUG_INSTRUCTOR }}"
"LOG_LEVEL=${{ vars.LOG_LEVEL }}"

10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# args without default values
FROM node as builder
ARG VITE_SLACK_APP_SUPABASE_API_URL=default \
VITE_SLACK_APP_SUPABASE_ANON_KEY=default

# Create app directory
WORKDIR /usr/src/app
Expand All @@ -8,6 +11,13 @@ COPY package.json yarn.lock ./
COPY apps/ ./apps/
COPY packages/ ./packages/

# important to preview env var with VITE so that is included in the build artifact
ENV VITE_SLACK_APP_SUPABASE_API_URL=$VITE_SLACK_APP_SUPABASE_API_URL
ENV VITE_SLACK_APP_SUPABASE_ANON_KEY=$VITE_SLACK_APP_SUPABASE_ANON_KEY

# verify environment vars
RUN export

RUN yarn install --frozen-lockfile
RUN yarn build

Expand Down
3 changes: 2 additions & 1 deletion apps/admin/src/supabase/SupabaseClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { createClient, SupabaseClient } from "@supabase/supabase-js";
console.log("Initializing Supabase client with provided URL and Anon Key.");

// Initialize Supabase client
const supabaseUrl = import.meta.env.VITE_SLACK_APP_SUPABASE_URL;
const supabaseUrl = import.meta.env.VITE_SLACK_APP_SUPABASE_API_URL;

const supabaseAnonKey = import.meta.env.VITE_SLACK_APP_SUPABASE_ANON_KEY;

const supabase: SupabaseClient = createClient(supabaseUrl, supabaseAnonKey);
Expand Down
4 changes: 4 additions & 0 deletions apps/admin/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
define: {
VITE_SLACK_APP_SUPABASE_API_URL: `'${process.env.VITE_SLACK_APP_SUPABASE_API_URL}'`,
VITE_SLACK_APP_SUPABASE_ANON_KEY: `'${process.env.VITE_SLACK_APP_SUPABASE_ANON_KEY}'`
}
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build:assistant-lib": "cd packages/assistant-lib && yarn codestyle:fix && yarn build && cd ../..",
"build:slack-app": "cd apps/slack-app && yarn codestyle:fix && yarn build && cd ../..",
"build:admin": "cd apps/admin && yarn codestyle:fix && yarn build && cd ../..",
"build": "yarn clean && yarn build:assistant-lib && yarn build:admin && yarn build:slack-app",
"build": "export && yarn clean && yarn build:assistant-lib && yarn build:admin && yarn build:slack-app",
"run:slack-app": "node ./apps/slack-app/dist/src/app.js"
},
"devDependencies": {
Expand Down

0 comments on commit d4b9741

Please sign in to comment.