Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

496 unify workflow v2 #552

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3a58f66
CI/CD - update the pipeline and make it work
duanxinhuan Oct 6, 2022
5ec76f2
CI/CD: update the work flow to test
duanxinhuan Oct 6, 2022
24b967c
CI/CD - update the work flow fix the bug
duanxinhuan Oct 6, 2022
53e6972
CI?CD get rid of the invalid environment
duanxinhuan Oct 6, 2022
9a2be7b
CI/CD test the flow
duanxinhuan Oct 6, 2022
18f09ff
CI/Cd test again
duanxinhuan Oct 6, 2022
122b749
CI/CD: test if environment variable is working
duanxinhuan Oct 6, 2022
13ff6a3
CI/CD add space to the env keyword
duanxinhuan Oct 6, 2022
be6fde1
CI/CD-try to add " to the environment variable
duanxinhuan Oct 6, 2022
82468e8
CI/CD update the environment section
duanxinhuan Oct 6, 2022
5f9fad7
CI/CD-create reusable workflow and pass value
duanxinhuan Oct 6, 2022
a070c52
CI/CD add checkout
duanxinhuan Oct 6, 2022
cd9df85
rename the work flow
duanxinhuan Oct 6, 2022
2efc936
CI/CD-update-the-reusable-workflow
duanxinhuan Oct 6, 2022
34624f5
CI/CD-update secret inherit
duanxinhuan Oct 6, 2022
2f969c7
CI/CD-update-the-reusable-workflow
duanxinhuan Oct 6, 2022
ae0568b
CI/CD fix the identation
duanxinhuan Oct 6, 2022
637517b
CI/CD-add-condition-on-push-or-dispatch
duanxinhuan Oct 6, 2022
257b78c
CI/CD: maintain the dotnet sdk with global json file
duanxinhuan Oct 7, 2022
bb1a355
fix the bug
duanxinhuan Oct 7, 2022
b8f5381
CI/CD: rename the use .net sdk session
duanxinhuan Oct 7, 2022
b3eda4c
CI/CD: delete unnecessary folders
duanxinhuan Oct 7, 2022
065ab82
CI/CD - add comments on the work flow
duanxinhuan Oct 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CI/CD-create reusable workflow and pass value
  • Loading branch information
duanxinhuan committed Oct 6, 2022
commit 5f9fad7b292cf5d66a05b93acf557165d58bea21
197 changes: 8 additions & 189 deletions .github/workflows/SSW.SophieBot.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,197 +14,16 @@ on:
- ".github/workflows/SSW.SophieBot.dev.yml"
- ".github/workflows/scripts/**"

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
BUILD_ENVIRONMENT: "${{ github.event_name == 'workflow_dispatch' && 'prod' || 'dev' }}"

defaults:
run:
shell: pwsh

jobs:
environment:
test-flow:
name: Test flow
runs-on: ubuntu-latest
steps:
- name: Test the build environment
run: echo "environment is ${{ env.BUILD_ENVIRONMENT }}"
build:
name: Build
call-work-flow:
runs-on: ubuntu-latest
environment:
name: "${{ env.BUILD_ENVIRONMENT }}"
environment: Deploy-Dev
steps:
- uses: actions/checkout@v2.3.4

- name: Use Node 16.x
uses: actions/setup-node@v2.4.0
with:
node-version: "16"
- name: Use BF CLI
run: npm install -g @microsoft/botframework-cli
- name: Use .Net sdk 6.0.x
uses: actions/setup-dotnet@v1.9.0
- uses: ./.github/workflows/reuse.workflow.yml
with:
dotnet-version: "6.0.x"

- name: Create appsettings file
uses: jsdaniell/create-json@1.1.2
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/upload-artifact@v2.2.4
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/upload-artifact@v2.3.1
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/upload-artifact@v2.3.1
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:
name: "${{ env.BUILD_ENVIRONMENT }}"
steps:
- uses: actions/checkout@v2.3.4

- name: Use .Net sdk 6.0.x
uses: actions/setup-dotnet@v1.9.0
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:
name: "${{ env.BUILD_ENVIRONMENT }}"
steps:
- uses: actions/checkout@v2.3.4

- uses: actions/download-artifact@v2
with:
name: "LUIS_Migrator_${{ github.run_id }}"
path: ${{ env.OUTPUT_DIR }}/luis-migrator

- name: Create appsettings file
uses: jsdaniell/create-json@1.1.2
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
BOT_APP_APPSETTINGS: ${{ secrets.BOT_APP_APPSETTINGS }}
LUIS_AUTHORING_KEY: ${{ secrets.LUIS_AUTHORING_KEY }}
BOT_WEBAPP_PUBLISH_PROFILE: ${{ secrets.BOT_WEBAPP_PUBLISH_PROFILE }}
LUIS_MIGRATOR_APPSETTINGS : ${{ secrets.LUIS_MIGRATOR_APPSETTINGS }}

Loading