Merge pull request #623 from SSWConsulting/609-add_logs #308
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy-Dev | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "bots/**" | |
- "libraries/**" | |
- "services/**" | |
- ".github/workflows/SSW.SophieBot.dev.yml" | |
- ".github/workflows/scripts/**" | |
workflow_dispatch: | |
concurrency: | |
group: SSWSophieBotDev-BuildAndDeploy | |
cancel-in-progress: true | |
env: | |
BUILD_FLOW: composer | |
BOT_NAME: SSWSophieBotDev | |
WEBAPP_NAME: SSWSophieBotDev-Linux | |
SOURCE_DIR: ${{ github.workspace }} | |
OUTPUT_DIR: ${{ github.workspace }}/output | |
LUIS_MIGRATOR_DIR: ${{ github.workspace }}/bots/employee-finder/src/SSW.SophieBot.LUIS.EmployeeFinder.Migrator | |
BOT_PROJECT_DIR: ${{ github.workspace }}/bots/employee-finder/src/SSW.SophieBot | |
BOT_PROJECT_NAME: SSW.SophieBot.csproj | |
PUBLISHING_PROFILE_NAME: SSW.Bots.Dev | |
LUIS_AUTHORING_ENDPOINT: https://australiaeast.api.cognitive.microsoft.com/ | |
LUIS_AUTHORING_REGION: australiaeast | |
defaults: | |
run: | |
shell: pwsh | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
environment: dev | |
steps: | |
- uses: actions/[email protected] | |
- name: Use Node 16.x | |
uses: actions/[email protected] | |
with: | |
node-version: "16" | |
- name: Use BF CLI | |
run: npm install -g @microsoft/botframework-cli | |
- name: Use .Net sdk 6.0.x | |
uses: actions/[email protected] | |
with: | |
dotnet-version: "6.0.x" | |
- name: Create appsettings file | |
uses: jsdaniell/[email protected] | |
with: | |
name: "appsettings.json" | |
json: ${{ secrets.BOT_APP_APPSETTINGS }} | |
dir: "bots/employee-finder/src/SSW.SophieBot/settings" | |
# Prepare working folders | |
- name: Prepare working folders | |
if: env.BUILD_FLOW == 'composer' | |
run: | | |
$generatedDirectory = "${{ env.BOT_PROJECT_DIR }}/generated" | |
# Clean and recreate the generated directory | |
if (Test-Path $generatedDirectory) | |
{ | |
Remove-Item -Path $generatedDirectory -Force -Recurse | |
} | |
$outputDirectory = "$generatedDirectory/interruption" | |
New-Item -Path /. -name $outputDirectory -ItemType "directory" | |
# Cross train LU models | |
- name: Cross train LU models | |
if: env.BUILD_FLOW == 'composer' | |
run: | | |
$sourceDirectory = "${{ env.BOT_PROJECT_DIR }}" | |
$outputDirectory = "${{ env.BOT_PROJECT_DIR }}/generated/interruption" | |
# Cross train models | |
bf luis:cross-train --in $sourceDirectory --out $outputDirectory --config $sourceDirectory/settings/cross-train.config.json --force | |
# List generated files | |
cd $outputDirectory | |
ls -R | |
# Publish LUIS models | |
- name: Publish LUIS | |
if: env.BUILD_FLOW == 'composer' | |
run: ${{ env.SOURCE_DIR }}/.github/workflows/scripts/Build-LUIS.ps1 -outputDirectory ./generated -sourceDirectory ./ -crossTrainedLUDirectory ./generated/interruption -authoringKey ${{ secrets.LUIS_AUTHORING_KEY }} -botName ${{ env.BOT_NAME }} -endpoint ${{ env.LUIS_AUTHORING_ENDPOINT }} -region ${{ env.LUIS_AUTHORING_REGION }} | |
working-directory: ${{ env.BOT_PROJECT_DIR }} | |
# Publish QnA models | |
- name: Publish QnA | |
if: env.BUILD_FLOW == 'composer' | |
run: | | |
$publishingProfileName = (${{ env.BUILD_FLOW }} -eq 'composer') ? "${{ env.PUBLISHING_PROFILE_NAME }}" : "" | |
${{ env.SOURCE_DIR }}/.github/workflows/scripts/Build-QnA.ps1 -botProjectFolder ./ -crossTrainedLUDirectory ./generated/interruption -publishingProfile $publishingProfileName | |
working-directory: ${{ env.BOT_PROJECT_DIR }} | |
# Publish Orchestrator models | |
# - name: Publish orchestrator | |
# if: env.BUILD_FLOW == 'composer' | |
# run: | | |
# cd ${{ env.BOT_PROJECT_DIR }} | |
# & "${{ env.SOURCE_DIR }}/.github/workflows/scripts/Build-Orchestrator.ps1" -outputDirectory ./generated -sourceDirectory ./ -crossTrainedLUDirectory ./generated/interruption -appSettingsFile ./settings/appsettings.json | |
# Upload bot models artifact | |
- name: Upload bot models artifact | |
if: env.BUILD_FLOW == 'composer' | |
uses: actions/[email protected] | |
with: | |
name: "Bot_Models_${{ github.run_id }}" | |
path: ${{ env.BOT_PROJECT_DIR }}/generated | |
if-no-files-found: error | |
# Create bot app publishing package | |
- name: Create bot publishing package | |
run: | | |
$publishingProfileName = (${{ env.BUILD_FLOW }} -eq 'composer') ? "${{ env.PUBLISHING_PROFILE_NAME }}" : "" | |
& "${{ env.SOURCE_DIR }}/.github/workflows/scripts/Publish-WebApp.ps1" -botProjectFolder ${{ env.BOT_PROJECT_DIR }} -botProjectName ${{ env.BOT_PROJECT_NAME }} -outputFolder "${{ env.OUTPUT_DIR }}/deploy" -publishingProfile $publishingProfileName | |
working-directory: ${{ env.BOT_PROJECT_DIR }} | |
# Create LUIS migrator publishing package | |
- name: Create LUIS migrator publishing package | |
run: dotnet publish -c Release -o "${{ env.OUTPUT_DIR }}/luis-migrator" --self-contained -r win-x64 | |
working-directory: ${{ env.LUIS_MIGRATOR_DIR }} | |
# Upload webapp artifact | |
- name: Upload webapp artifact | |
uses: actions/[email protected] | |
with: | |
name: "Bot_Webapp_${{ github.run_id }}" | |
path: ${{ env.OUTPUT_DIR }}/deploy | |
if-no-files-found: error | |
# Upload LUIS migrator artifact | |
- name: Upload LUIS migrator artifact | |
uses: actions/[email protected] | |
with: | |
name: "LUIS_Migrator_${{ github.run_id }}" | |
path: ${{ env.OUTPUT_DIR }}/luis-migrator | |
if-no-files-found: error | |
deploy-web-app: | |
name: Deploy web app | |
needs: build | |
runs-on: ubuntu-latest | |
environment: dev | |
steps: | |
- uses: actions/[email protected] | |
- name: Use .Net sdk 6.0.x | |
uses: actions/[email protected] | |
with: | |
dotnet-version: "6.0.x" | |
- uses: actions/download-artifact@v2 | |
with: | |
name: "Bot_Webapp_${{ github.run_id }}" | |
path: ${{ env.OUTPUT_DIR }}/deploy | |
# Deploy the web app to azure | |
- name: "Deploy Azure Web App" | |
uses: Azure/webapps-deploy@v2 | |
with: | |
app-Name: ${{ env.WEBAPP_NAME }} | |
publish-profile: ${{ secrets.BOT_WEBAPP_PUBLISH_PROFILE }} | |
package: "${{ env.OUTPUT_DIR }}/deploy" | |
migrate-luis-model: | |
name: Migrate LUIS model | |
needs: build | |
runs-on: windows-latest | |
environment: dev | |
steps: | |
- uses: actions/[email protected] | |
- uses: actions/download-artifact@v2 | |
with: | |
name: "LUIS_Migrator_${{ github.run_id }}" | |
path: ${{ env.OUTPUT_DIR }}/luis-migrator | |
- name: Create appsettings file | |
uses: jsdaniell/[email protected] | |
with: | |
name: "appsettings.json" | |
json: ${{ secrets.LUIS_MIGRATOR_APPSETTINGS }} | |
dir: "output/luis-migrator" | |
- name: Run LUIS migrator | |
run: .\SSW.SophieBot.LUIS.EmployeeFinder.Migrator | |
working-directory: ${{ env.OUTPUT_DIR }}/luis-migrator |