diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml deleted file mode 100644 index 510027e19..000000000 --- a/.github/workflows/blank.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: blank - -on: - workflow_dispatch: - -jobs: - EnvironmentDeploy: - runs-on: windows-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 \ No newline at end of file diff --git a/.github/workflows/publicrecordingbot_scheduled-cluster-stop.yml b/.github/workflows/cluster-autostop.yml similarity index 95% rename from .github/workflows/publicrecordingbot_scheduled-cluster-stop.yml rename to .github/workflows/cluster-autostop.yml index 4eec580b2..c031b0221 100644 --- a/.github/workflows/publicrecordingbot_scheduled-cluster-stop.yml +++ b/.github/workflows/cluster-autostop.yml @@ -1,4 +1,4 @@ -name: Scheduled AKS Cluster Stop +name: Cluster - Auto-Stop # Stop the AKS cluster every day at midnight UTC to save costs on: @@ -45,7 +45,7 @@ jobs: stop-cluster: name: Stop AKS Cluster needs: print-info - uses: ./.github/workflows/publicrecordingbot_manage-cluster.yml + uses: ./.github/workflows/routine-managecluster.yml with: action: 'stop' cluster-name: ${{ vars.AKS_CLUSTER_NAME }} diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 000000000..684413db8 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,337 @@ +name: Continuous Integration +run-name: ${{ github.event_name == 'pull_request' && format('Pull Request "{0}" - Complete CI Pipeline', github.event.pull_request.title) || (github.event_name == 'schedule' && 'Scheduled Weekly Deployment and Testing' || format('Main Branch Deploy - {0}', github.sha)) }} + +on: + pull_request: + branches: + - main + push: + branches: + - main + paths: + - src + - scripts + - build + - deploy + - .github/workflows/continuous-integration.yml + schedule: + # Sunday at 2 PM UTC (Sunday afternoon) + - cron: '0 14 * * 0' + +env: + PR_NUMBER: ${{ github.event.number }} + +concurrency: + group: aks-sample-environment + cancel-in-progress: false + +jobs: + check-recording-bot-changes: + runs-on: ubuntu-latest + outputs: + build: ${{ steps.changes.outputs.build }} + deploy: ${{ steps.changes.outputs.deploy }} + docs: ${{ steps.changes.outputs.docs }} + scripts: ${{ steps.changes.outputs.scripts }} + src: ${{ steps.changes.outputs.src }} + steps: + - uses: actions/checkout@v4 + - shell: pwsh + id: changes + run: | + if ('${{ github.event_name }}' -eq 'push' -or '${{ github.event_name }}' -eq 'schedule') { + # For main branch pushes and scheduled runs, always consider all changes as relevant + echo "build=True" >> $env:GITHUB_OUTPUT + echo "deploy=True" >> $env:GITHUB_OUTPUT + echo "docs=True" >> $env:GITHUB_OUTPUT + echo "scripts=True" >> $env:GITHUB_OUTPUT + echo "src=True" >> $env:GITHUB_OUTPUT + } else { + # For pull requests, check actual changes + git fetch + git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} + $diff = git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} + + # Check if a file has changed (added, modified, deleted) + $BuildDiff = $diff | Where-Object { $_ -match '^build/' } + $DeployDiff = $diff | Where-Object { $_ -match '^deploy/' } + $DocsDiff = $diff | Where-Object { $_ -match '^docs/' -or $_ -match '.md$' } + $ScriptsDiff = $diff | Where-Object { $_ -match '^scripts/' } + $SrcDiff = $diff | Where-Object { $_ -match '^src/' } + + $HasBuildDiff = $BuildDiff.Length -gt 0 + $HasDeployDiff = $DeployDiff.Length -gt 0 + $HasDocsDiff = $DocsDiff.Length -gt 0 + $HasScriptsDiff = $ScriptsDiff.Length -gt 0 + $HasSrcDiff = $SrcDiff.Length -gt 0 + + # Set the outputs + echo "build=$HasBuildDiff" >> $env:GITHUB_OUTPUT + echo "deploy=$HasDeployDiff" >> $env:GITHUB_OUTPUT + echo "docs=$HasDocsDiff" >> $env:GITHUB_OUTPUT + echo "scripts=$HasScriptsDiff" >> $env:GITHUB_OUTPUT + echo "src=$HasSrcDiff" >> $env:GITHUB_OUTPUT + } + + chart-version-checks: + runs-on: ubuntu-latest + needs: check-recording-bot-changes + if: | + needs.check-recording-bot-changes.outputs.build == 'True' || + needs.check-recording-bot-changes.outputs.deploy == 'True' || + needs.check-recording-bot-changes.outputs.scripts == 'True' || + needs.check-recording-bot-changes.outputs.src == 'True' + + defaults: + run: + working-directory: deploy + + outputs: + app-version-check-passed: ${{ steps.app-version-check.outcome }} + chart-version-check-passed: ${{ steps.chart-version-check.outcome }} + + steps: + - uses: actions/checkout@v4 + - run: | + git fetch + git branch -a + + - name: Install Helm + uses: azure/setup-helm@v3 + with: + version: 'latest' + + - name: Lint Helm Chart + working-directory: deploy/teams-recording-bot + if: needs.check-recording-bot-changes.outputs.deploy == 'True' + run: | + echo "🔍 Linting Helm chart..." + helm lint + echo "✅ Helm chart lint passed" + + - name: Check App Version Change (PR only) + id: app-version-check + if: | + github.event_name == 'pull_request' && + ( + needs.check-recording-bot-changes.outputs.build == 'True' || + needs.check-recording-bot-changes.outputs.scripts == 'True' || + needs.check-recording-bot-changes.outputs.src == 'True' + ) + shell: bash + run: | + echo "🔍 Checking app version changes..." + oldVersion=$(MSYS_NO_PATHCONV=1 git show remotes/origin/$GITHUB_BASE_REF:deploy/teams-recording-bot/Chart.yaml | sed -n "s/^appVersion: \([0-9\.]*\)$/\1/p") + echo "Previous app Version: $oldVersion" + [ -z "$oldVersion" ] && exit 1 + + newVersion=$(cat teams-recording-bot/Chart.yaml | sed -n "s/^appVersion: \([0-9\.]*\)$/\1/p") + echo "New app Version: $newVersion" + [ -z "$newVersion" ] && exit 1 + + echo "Check if app Version was updated" + [ "$newVersion" = "$oldVersion" ] && exit 1 + newerVersion=$(echo -e "$oldVersion\n$newVersion" | sort -V | tail -1) + [ "$newerVersion" = "$newVersion" ] || exit 1 + echo "✅ Success app Version was updated!" + + - name: Check Chart Version Change (PR only) + if: github.event_name == 'pull_request' && needs.check-recording-bot-changes.outputs.deploy == 'True' + shell: bash + run: | + echo "🔍 Checking chart version changes..." + oldVersion=$(MSYS_NO_PATHCONV=1 git show remotes/origin/$GITHUB_BASE_REF:deploy/teams-recording-bot/Chart.yaml | sed -n "s/^version: \([0-9\.]*\)$/\1/p") + echo "Previous Version: $oldVersion" + [ -z "$oldVersion" ] && exit 1 + + newVersion=$(cat teams-recording-bot/Chart.yaml | sed -n "s/^version: \([0-9\.]*\)$/\1/p") + echo "New Version: $newVersion" + [ -z "$newVersion" ] && exit 1 + + echo "Check if Version was updated" + [ "$newVersion" = "$oldVersion" ] && exit 1 + newerVersion=$(echo -e "$oldVersion\n$newVersion" | sort -V | tail -1) + [ "$newerVersion" = "$newVersion" ] || exit 1 + echo "✅ Success Version was updated!" + + retag-and-push: + runs-on: ubuntu-latest + needs: [check-recording-bot-changes, chart-version-checks] + if: | + (github.event_name == 'push' || github.event_name == 'schedule') && + needs.chart-version-checks.result == 'success' && + ( + needs.check-recording-bot-changes.outputs.build == 'True' || + needs.check-recording-bot-changes.outputs.scripts == 'True' || + needs.check-recording-bot-changes.outputs.src == 'True' + ) + + permissions: + packages: write + + outputs: + image-exists: ${{ steps.check-image.outputs.image-exists }} + + steps: + - uses: actions/checkout@v4 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Generate Docker image tag + id: generate-tag + run: | + hash=$(find src build scripts -type f -exec sha256sum {} \; | sort | sha256sum | awk '{print $1}') + echo "tag=$hash" >> $GITHUB_OUTPUT + + - name: Check if image exists + id: check-image + run: | + if docker manifest inspect ${{ vars.CR_NAMESPACE_REPOSITORY }}:${{ steps.generate-tag.outputs.tag }} > /dev/null 2>&1; then + echo "Image already exists" + echo "image-exists=true" >> $GITHUB_OUTPUT + else + echo "image-exists=false" >> $GITHUB_OUTPUT + fi + + - name: Pull PR image and retag as latest + if: steps.check-image.outputs.image-exists == 'true' + run: | + TAG="${{ steps.generate-tag.outputs.tag }}" + REGISTRY="${{ vars.CR_NAMESPACE_REPOSITORY }}" + + echo "🔍 Pulling image with tag: $TAG" + docker pull ${REGISTRY}:${TAG} + + echo "🏷️ Retagging image as latest" + docker tag ${REGISTRY}:${TAG} ${REGISTRY}:latest + + echo "🚀 Pushing latest image" + docker push ${REGISTRY}:latest + + echo "✅ Successfully promoted ${REGISTRY}:${TAG} to ${REGISTRY}:latest" + + start-cluster: + needs: [check-recording-bot-changes, chart-version-checks] + if: | + needs.chart-version-checks.result == 'success' && + ( + needs.check-recording-bot-changes.outputs.build == 'True' || + needs.check-recording-bot-changes.outputs.deploy == 'True' || + needs.check-recording-bot-changes.outputs.scripts == 'True' || + needs.check-recording-bot-changes.outputs.src == 'True' + ) + uses: ./.github/workflows/routine-managecluster.yml + with: + action: 'start' + cluster-name: ${{ vars.AKS_CLUSTER_NAME }} + resource-group: ${{ vars.AKS_RESOURCE_GROUP }} + subscription: ${{ vars.AZURE_SUBSCRIPTION_ID }} + secrets: + AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} + + generate-image-tag: + needs: [check-recording-bot-changes, chart-version-checks, retag-and-push] + if: | + always() && + needs.chart-version-checks.result == 'success' && + ( + needs.check-recording-bot-changes.outputs.build == 'True' || + needs.check-recording-bot-changes.outputs.src == 'True' || + needs.check-recording-bot-changes.outputs.scripts == 'True' + ) && + ( + github.event_name == 'pull_request' || + ((github.event_name == 'push' || github.event_name == 'schedule') && needs.retag-and-push.outputs.image-exists == 'false') + ) + runs-on: ubuntu-latest + + outputs: + image-tag: ${{ steps.generate-tag.outputs.tag }} + + steps: + - uses: actions/checkout@v4 + + - name: Generate content-based image tag + id: generate-tag + run: | + hash=$(find src build scripts -type f -exec sha256sum {} \; | sort | sha256sum | awk '{print $1}') + if [ '${{ github.event_name }}' = 'pull_request' ]; then + echo "tag=pr-${{ github.event.number }}-${hash:0:8}" >> $GITHUB_OUTPUT + else + echo "tag=latest" >> $GITHUB_OUTPUT + fi + + build-docker-image: + needs: [check-recording-bot-changes, chart-version-checks, retag-and-push, generate-image-tag] + if: | + always() && + needs.chart-version-checks.result == 'success' && + ( + needs.check-recording-bot-changes.outputs.build == 'True' || + needs.check-recording-bot-changes.outputs.src == 'True' || + needs.check-recording-bot-changes.outputs.scripts == 'True' + ) && + ( + github.event_name == 'pull_request' || + ((github.event_name == 'push' || github.event_name == 'schedule') && needs.retag-and-push.outputs.image-exists == 'false') + ) + uses: ./.github/workflows/routine-buildimage.yml + permissions: + packages: write + with: + tag: ${{ needs.generate-image-tag.outputs.image-tag }} + cr-namespace-repository: ${{ vars.CR_NAMESPACE_REPOSITORY }} + secrets: inherit + + deploy-to-environment: + needs: [check-recording-bot-changes, chart-version-checks, start-cluster, build-docker-image, retag-and-push, generate-image-tag] + if: | + always() && + needs.start-cluster.result == 'success' && + ( + needs.build-docker-image.result == 'success' || + (needs.retag-and-push.result == 'success' && (github.event_name == 'push' || github.event_name == 'schedule')) || + (needs.check-recording-bot-changes.outputs.deploy == 'True' && (needs.build-docker-image.result == 'skipped' || needs.retag-and-push.result == 'skipped')) + ) + uses: ./.github/workflows/routine-deployenvironment.yml + with: + environment-name: aks-sample + port: '28550' + cluster-name: ${{ vars.AKS_CLUSTER_NAME }} + resource-group: ${{ vars.AKS_RESOURCE_GROUP }} + subscription: ${{ vars.AZURE_SUBSCRIPTION_ID }} + namespace: teams-recording-bot + host: ${{ needs.start-cluster.outputs.cluster-fqdn }} + image-registry: ${{ vars.CR_REGISTRY }} + image-name: ${{ vars.CR_IMAGE_NAME }} + image-tag: ${{ needs.generate-image-tag.outputs.image-tag || 'latest' }} + public-ip: ${{ needs.start-cluster.outputs.cluster-ip }} + tls-email: ${{ vars.TLS_EMAIL }} + enable-nginx: true + replica-count: '1' + secrets: + AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} + + run-tests: + needs: [check-recording-bot-changes, chart-version-checks, start-cluster, build-docker-image, deploy-to-environment, generate-image-tag] + if: always() && needs.deploy-to-environment.result == 'success' + uses: ./.github/workflows/routine-runtests.yml + with: + headless-mode: true + test-environment: ${{ needs.generate-image-tag.outputs.image-tag || 'latest' }} + github-issue-number: ${{ github.event.number || '' }} + secrets: + USER_A_USERNAME: ${{ vars.TEST_USER_A_USERNAME }} + USER_A_PASSWORD: ${{ secrets.TEST_USER_A_PASSWORD }} + USER_A_SEED: ${{ secrets.TEST_USER_A_SEED }} + USER_B_USERNAME: ${{ vars.TEST_USER_B_USERNAME }} + USER_B_PASSWORD: ${{ secrets.TEST_USER_B_PASSWORD }} + USER_B_SEED: ${{ secrets.TEST_USER_B_SEED }} + USER_C_USERNAME: ${{ vars.TEST_USER_C_USERNAME }} + USER_C_PASSWORD: ${{ secrets.TEST_USER_C_PASSWORD }} + USER_C_SEED: ${{ secrets.TEST_USER_C_SEED }} \ No newline at end of file diff --git a/.github/workflows/publicrecordingbot_pull-request-cd.yml b/.github/workflows/publicrecordingbot_pull-request-cd.yml deleted file mode 100644 index 2cf32b26c..000000000 --- a/.github/workflows/publicrecordingbot_pull-request-cd.yml +++ /dev/null @@ -1,71 +0,0 @@ -name: Recording Bot Release Docker Image - -on: - push: - branches: - - main - - master - paths: - - src - - scripts - - build - - .github/workflows/publicrecordingbot_pull-request-cd.yml - -jobs: - retag-and-push: - runs-on: ubuntu-latest - - permissions: - packages: write - - steps: - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Generate Docker image tag - id: generate-tag - run: | - hash=$(find ../../src ../../build ../../scripts -type f -exec sha256sum {} \; | sort | sha256sum | awk '{print $1}') - echo "tag=$hash" >> $GITHUB_OUTPUT - - - name: Check if image exists - id: check-image - run: | - if docker manifest inspect ${{ vars.CR_NAMESPACE_REPOSITORY }}:${{ steps.generate-tag.outputs.tag }} > /dev/null 2>&1; then - echo "Image already exists" - echo "image-exists=true" >> $GITHUB_OUTPUT - else - echo "image-exists=false" >> $GITHUB_OUTPUT - fi - - - name: Pull PR image and retag as latest - if: steps.check-image.outputs.image-exists == 'true' - run: | - TAG="${{ steps.generate-tag.outputs.tag }}" - REGISTRY="${{ vars.CR_NAMESPACE_REPOSITORY }}" - - echo "🔍 Pulling image with tag: $TAG" - docker pull ${REGISTRY}:${TAG} - - echo "🏷️ Retagging image as latest" - docker tag ${REGISTRY}:${TAG} ${REGISTRY}:latest - - echo "🚀 Pushing latest image" - docker push ${REGISTRY}:latest - - echo "✅ Successfully promoted ${REGISTRY}:${TAG} to ${REGISTRY}:latest" - - build-fallback: - needs: retag-and-push - if: needs.retag-and-push.outputs.image-exists == 'false' - uses: ./.github/workflows/publicrecordingbot_docker-build.yml - permissions: - packages: write - with: - tag: latest - cr-namespace-repository: ${{ vars.CR_NAMESPACE_REPOSITORY }} - secrets: inherit \ No newline at end of file diff --git a/.github/workflows/publicrecordingbot_pull-request-ci.yml b/.github/workflows/publicrecordingbot_pull-request-ci.yml deleted file mode 100644 index 6486a1a74..000000000 --- a/.github/workflows/publicrecordingbot_pull-request-ci.yml +++ /dev/null @@ -1,210 +0,0 @@ -name: Recording Bot Pull Request CI -run-name: Pull Request "${{github.event.pull_request.title}}" - Complete CI Pipeline - -on: - pull_request: - branches: - - main - - master - -env: - PR_NUMBER: ${{ github.event.number }} - IMAGE_TAG: pr-${{ github.event.number }} - -jobs: - check-recording-bot-changes: - runs-on: ubuntu-latest - outputs: - build: ${{ steps.changes.outputs.build }} - deploy: ${{ steps.changes.outputs.deploy }} - docs: ${{ steps.changes.outputs.docs }} - scripts: ${{ steps.changes.outputs.scripts }} - src: ${{ steps.changes.outputs.src }} - steps: - - uses: actions/checkout@v4 - - shell: pwsh - id: changes - run: | - # Diff latest commit with latest main commit for Recording Bot - git fetch - git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} - $diff = git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} - - # Check if a file has changed (added, modified, deleted) - $BuildDiff = $diff | Where-Object { $_ -match '^build/' } - $DeployDiff = $diff | Where-Object { $_ -match '^deploy/' } - $DocsDiff = $diff | Where-Object { $_ -match '^docs/' -or $_ -match '.md$' } - $ScriptsDiff = $diff | Where-Object { $_ -match '^scripts/' } - $SrcDiff = $diff | Where-Object { $_ -match '^src/' } - - $HasBuildDiff = $BuildDiff.Length -gt 0 - $HasDeployDiff = $DeployDiff.Length -gt 0 - $HasDocsDiff = $DocsDiff.Length -gt 0 - $HasScriptsDiff = $ScriptsDiff.Length -gt 0 - $HasSrcDiff = $SrcDiff.Length -gt 0 - - # Set the outputs - echo "build=$HasBuildDiff" >> $env:GITHUB_OUTPUT - echo "deploy=$HasDeployDiff" >> $env:GITHUB_OUTPUT - echo "docs=$HasDocsDiff" >> $env:GITHUB_OUTPUT - echo "scripts=$HasScriptsDiff" >> $env:GITHUB_OUTPUT - echo "src=$HasSrcDiff" >> $env:GITHUB_OUTPUT - - chart-version-checks: - runs-on: ubuntu-latest - needs: check-recording-bot-changes - if: | - needs.check-recording-bot-changes.outputs.build == 'True' || - needs.check-recording-bot-changes.outputs.deploy == 'True' || - needs.check-recording-bot-changes.outputs.scripts == 'True' || - needs.check-recording-bot-changes.outputs.src == 'True' - - defaults: - run: - working-directory: deploy - - outputs: - app-version-check-passed: ${{ steps.app-version-check.outcome }} - chart-version-check-passed: ${{ steps.chart-version-check.outcome }} - - steps: - - uses: actions/checkout@v4 - - run: | - git fetch - git branch -a - - - name: Install Helm - uses: azure/setup-helm@v3 - with: - version: 'latest' - - - name: Lint Helm Chart - working-directory: deploy/teams-recording-bot - if: needs.check-recording-bot-changes.outputs.deploy == 'True' - run: | - echo "🔍 Linting Helm chart..." - helm lint - echo "✅ Helm chart lint passed" - - - name: Check App Version Change - id: app-version-check - if: | - needs.check-recording-bot-changes.outputs.build == 'True' || - needs.check-recording-bot-changes.outputs.scripts == 'True' || - needs.check-recording-bot-changes.outputs.src == 'True' - shell: bash - run: | - echo "🔍 Checking app version changes..." - oldVersion=$(MSYS_NO_PATHCONV=1 git show remotes/origin/$GITHUB_BASE_REF:deploy/teams-recording-bot/Chart.yaml | sed -n "s/^appVersion: \([0-9\.]*\)$/\1/p") - echo "Previous app Version: $oldVersion" - [ -z "$oldVersion" ] && exit 1 - - newVersion=$(cat teams-recording-bot/Chart.yaml | sed -n "s/^appVersion: \([0-9\.]*\)$/\1/p") - echo "New app Version: $newVersion" - [ -z "$newVersion" ] && exit 1 - - echo "Check if app Version was updated" - [ "$newVersion" = "$oldVersion" ] && exit 1 - newerVersion=$(echo -e "$oldVersion\n$newVersion" | sort -V | tail -1) - [ "$newerVersion" = "$newVersion" ] || exit 1 - echo "✅ Success app Version was updated!" - - - name: Check Chart Version Change - if: needs.check-recording-bot-changes.outputs.deploy == 'True' - shell: bash - run: | - echo "🔍 Checking chart version changes..." - oldVersion=$(MSYS_NO_PATHCONV=1 git show remotes/origin/$GITHUB_BASE_REF:deploy/teams-recording-bot/Chart.yaml | sed -n "s/^version: \([0-9\.]*\)$/\1/p") - echo "Previous Version: $oldVersion" - [ -z "$oldVersion" ] && exit 1 - - newVersion=$(cat teams-recording-bot/Chart.yaml | sed -n "s/^version: \([0-9\.]*\)$/\1/p") - echo "New Version: $newVersion" - [ -z "$newVersion" ] && exit 1 - - echo "Check if Version was updated" - [ "$newVersion" = "$oldVersion" ] && exit 1 - newerVersion=$(echo -e "$oldVersion\n$newVersion" | sort -V | tail -1) - [ "$newerVersion" = "$newVersion" ] || exit 1 - echo "✅ Success Version was updated!" - - start-cluster: - needs: [check-recording-bot-changes, chart-version-checks] - if: | - needs.chart-version-checks.result == 'success' && - ( - needs.check-recording-bot-changes.outputs.build == 'True' || - needs.check-recording-bot-changes.outputs.deploy == 'True' || - needs.check-recording-bot-changes.outputs.scripts == 'True' || - needs.check-recording-bot-changes.outputs.src == 'True' - ) - uses: ./.github/workflows/publicrecordingbot_manage-cluster.yml - with: - action: 'start' - cluster-name: ${{ vars.AKS_CLUSTER_NAME }} - resource-group: ${{ vars.AKS_RESOURCE_GROUP }} - subscription: ${{ vars.AZURE_SUBSCRIPTION_ID }} - secrets: - AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} - - build-docker-image: - needs: [check-recording-bot-changes, chart-version-checks] - if: | - needs.chart-version-checks.result == 'success' && - ( - needs.check-recording-bot-changes.outputs.build == 'True' || - needs.check-recording-bot-changes.outputs.src == 'True' || - needs.check-recording-bot-changes.outputs.scripts == 'True' - ) - uses: ./.github/workflows/publicrecordingbot_docker-build.yml - permissions: - packages: write - with: - cr-namespace-repository: ${{ vars.CR_NAMESPACE_REPOSITORY }} - secrets: inherit - - deploy-to-test-environment: - needs: [check-recording-bot-changes, chart-version-checks, start-cluster, build-docker-image] - if: | - needs.start-cluster.result == 'success' && - ( - needs.build-docker-image.result == 'success' || - needs.check-recording-bot-changes.outputs.deploy == 'True' - ) - uses: ./.github/workflows/publicrecordingbot_deploy-environment.yml - with: - environment-name: aks-sample - port: '28550' - cluster-name: ${{ vars.AKS_CLUSTER_NAME }} - resource-group: ${{ vars.AKS_RESOURCE_GROUP }} - subscription: ${{ vars.AZURE_SUBSCRIPTION_ID }} - namespace: teams-recording-bot - host: ${{ needs.start-cluster.outputs.cluster-fqdn }} - image-registry: ${{ vars.CR_REGISTRY }} - image-name: ${{ vars.CR_IMAGE_NAME }} - image-tag: ${{ needs.build-docker-image.outputs.image-tag || 'latest' }} - public-ip: ${{ needs.start-cluster.outputs.cluster-ip }} - tls-email: ${{ vars.TLS_EMAIL }} - enable-nginx: true - replica-count: '1' - secrets: - AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }} - - run-tests: - needs: [check-recording-bot-changes, chart-version-checks, start-cluster, build-docker-image, deploy-to-test-environment] - if: needs.deploy-to-test-environment.result == 'success' - uses: ./.github/workflows/publicrecordingbot_dotnet-test.yml - with: - headless-mode: true - test-environment: pr-${{ github.event.number }} - github-issue-number: ${{ github.event.number }} - secrets: - USER_A_USERNAME: ${{ vars.TEST_USER_A_USERNAME }} - USER_A_PASSWORD: ${{ secrets.TEST_USER_A_PASSWORD }} - USER_A_SEED: ${{ secrets.TEST_USER_A_SEED }} - USER_B_USERNAME: ${{ vars.TEST_USER_B_USERNAME }} - USER_B_PASSWORD: ${{ secrets.TEST_USER_B_PASSWORD }} - USER_B_SEED: ${{ secrets.TEST_USER_B_SEED }} - USER_C_USERNAME: ${{ vars.TEST_USER_C_USERNAME }} - USER_C_PASSWORD: ${{ secrets.TEST_USER_C_PASSWORD }} - USER_C_SEED: ${{ secrets.TEST_USER_C_SEED }} \ No newline at end of file diff --git a/.github/workflows/publicrecordingbot_docker-build.yml b/.github/workflows/routine-buildimage.yml similarity index 94% rename from .github/workflows/publicrecordingbot_docker-build.yml rename to .github/workflows/routine-buildimage.yml index 6997d31fe..549760def 100644 --- a/.github/workflows/publicrecordingbot_docker-build.yml +++ b/.github/workflows/routine-buildimage.yml @@ -1,4 +1,4 @@ -name: Build and Push Docker Image to CR +name: Routine - Build Image on: workflow_call: @@ -23,10 +23,6 @@ jobs: permissions: packages: write - defaults: - run: - working-directory: Samples/PublicSamples/RecordingBot - outputs: image-tag: ${{ steps.generate-tag.outputs.tag }} diff --git a/.github/workflows/publicrecordingbot_deploy-environment.yml b/.github/workflows/routine-deployenvironment.yml similarity index 99% rename from .github/workflows/publicrecordingbot_deploy-environment.yml rename to .github/workflows/routine-deployenvironment.yml index 7ecfdf754..8e2c91bdc 100644 --- a/.github/workflows/publicrecordingbot_deploy-environment.yml +++ b/.github/workflows/routine-deployenvironment.yml @@ -1,4 +1,4 @@ -name: Deploy Teams Recording Bot +name: Routine - Deploy Environment on: workflow_call: diff --git a/.github/workflows/publicrecordingbot_manage-cluster.yml b/.github/workflows/routine-managecluster.yml similarity index 99% rename from .github/workflows/publicrecordingbot_manage-cluster.yml rename to .github/workflows/routine-managecluster.yml index 2a0e49576..4f0626215 100644 --- a/.github/workflows/publicrecordingbot_manage-cluster.yml +++ b/.github/workflows/routine-managecluster.yml @@ -1,4 +1,4 @@ -name: Manage AKS Cluster +name: Routine - Manage Cluster # Triggered by other workflows on: diff --git a/.github/workflows/publicrecordingbot_dotnet-test.yml b/.github/workflows/routine-runtests.yml similarity index 99% rename from .github/workflows/publicrecordingbot_dotnet-test.yml rename to .github/workflows/routine-runtests.yml index 11b40f3f9..d3b1c8307 100644 --- a/.github/workflows/publicrecordingbot_dotnet-test.yml +++ b/.github/workflows/routine-runtests.yml @@ -1,4 +1,4 @@ -name: Recording Bot Test +name: Routine - Run Tests on: workflow_call: diff --git a/.github/workflows/publicrecordingbot_codeql.yml b/.github/workflows/scan-codeql.yml similarity index 96% rename from .github/workflows/publicrecordingbot_codeql.yml rename to .github/workflows/scan-codeql.yml index 3214541b0..d9b6cd108 100644 --- a/.github/workflows/publicrecordingbot_codeql.yml +++ b/.github/workflows/scan-codeql.yml @@ -1,16 +1,14 @@ -name: "Recording Bot CodeQL" +name: "Scan - CodeQL" on: push: branches: - main - - master pull_request: branches: - main - - master schedule: - - cron: "24 5 * * 5" + - cron: "0 0 * * 1" # Every Monday at 00:00 UTC jobs: analyze: diff --git a/.github/workflows/sonarcloud.yaml b/.github/workflows/scan-sonarcloud.yml similarity index 98% rename from .github/workflows/sonarcloud.yaml rename to .github/workflows/scan-sonarcloud.yml index 988fa60c4..d848bec58 100644 --- a/.github/workflows/sonarcloud.yaml +++ b/.github/workflows/scan-sonarcloud.yml @@ -1,4 +1,4 @@ -name: SonarCloud +name: Scan - SonarCloud on: push: branches: diff --git a/.github/workflows/docker-image-scan.yml b/.github/workflows/scan-trivy.yml similarity index 94% rename from .github/workflows/docker-image-scan.yml rename to .github/workflows/scan-trivy.yml index c037b6c90..1c28828a2 100644 --- a/.github/workflows/docker-image-scan.yml +++ b/.github/workflows/scan-trivy.yml @@ -1,8 +1,8 @@ -name: Docker Image Scan +name: Scan - Trivy on: schedule: - - cron: '0 0 * * 1' # Jeden Montag um 00:00 Uhr + - cron: '0 0 * * 1' # Mondays at 00:00 UTC workflow_dispatch: push: branches: diff --git a/README.md b/README.md index 53911d2d2..a44d02df9 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ -> [!NOTE] -> Public Samples are provided by developers from the Microsoft Graph community. -> Public Samples are not official Microsoft Communication samples, and not supported by the Microsoft Communication engineering team. It is recommended that you contact the sample owner before using code from Public Samples in production systems. - ---- +# AKS-Sample +[![Continuous Integration](https://github.com/LM-Development/aks-sample/actions/workflows/continuous-integration.yml/badge.svg?branch=main)](https://github.com/LM-Development/aks-sample/actions/workflows/continuous-integration.yml) **Title:** RecordingBot diff --git a/deploy/teams-recording-bot/Chart.yaml b/deploy/teams-recording-bot/Chart.yaml index e554be88f..403072850 100644 --- a/deploy/teams-recording-bot/Chart.yaml +++ b/deploy/teams-recording-bot/Chart.yaml @@ -16,12 +16,12 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.4.7 +version: 1.5.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: 1.3.6 +appVersion: 1.4.0 dependencies: - name: ingress-nginx diff --git a/deploy/teams-recording-bot/templates/deployment.yaml b/deploy/teams-recording-bot/templates/deployment.yaml index dcbea75ea..8af298934 100644 --- a/deploy/teams-recording-bot/templates/deployment.yaml +++ b/deploy/teams-recording-bot/templates/deployment.yaml @@ -60,7 +60,7 @@ spec: command: - powershell - Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine; - - .\halt_termination.ps1 + - .\halt_termination.ps1 *>> halt_termination.log ports: - containerPort: {{ .Values.internal.port }} - containerPort: {{ .Values.internal.media }} diff --git a/docs/tutorials/deploy/3-build.md b/docs/tutorials/deploy/3-build.md index af2024754..a1057cea6 100644 --- a/docs/tutorials/deploy/3-build.md +++ b/docs/tutorials/deploy/3-build.md @@ -34,12 +34,6 @@ Resolving deltas: 100% (8606/8606), done. Updating files: 100% (1289/1289), done. ``` -Now we navigate to the aks sample in the repository we just downloaded. - -```powershell -cd .\aks-sample\Samples\PublicSamples\RecordingBot\ -``` - ## Build the application To build the application we will push the dockerfile and the source code of the AKS sample to our diff --git a/docs/tutorials/deploy/5-helm.md b/docs/tutorials/deploy/5-helm.md index 1e77569bb..2925bd820 100644 --- a/docs/tutorials/deploy/5-helm.md +++ b/docs/tutorials/deploy/5-helm.md @@ -7,12 +7,6 @@ change the directory since building the Docker container we can continue with [d cd C:\Users\User\recordingbottutorial ``` -And change the directory to the sample project in the repository. - -```powershell -cd .\aks-sample\Samples\PublicSamples\RecordingBot\ -``` - ## Deploy Cert Manager Like any local media bots, the sample needs a properly signed certificate, with a trust chain up to diff --git a/scripts/halt_termination.ps1 b/scripts/halt_termination.ps1 index 9c45ec84f..2f83b63ea 100644 --- a/scripts/halt_termination.ps1 +++ b/scripts/halt_termination.ps1 @@ -6,19 +6,26 @@ while($continue) { try { + Write-Host "Calling endpoint to check for active calls..." $result = Invoke-WebRequest -Uri "http://localhost:$CallSignalingPort2/calls" -UseBasicParsing - if ($result.Content) + Write-Host "Response content: $($result.Content)" + $calls = $result.Content | ConvertFrom-Json + + if ($calls.Count -gt 0) { + Write-Host "Active calls detected. Halting termination." Start-Sleep -Seconds 60 } else { + Write-Host "No active calls. Proceeding with termination." $continue = $false } } catch { - "Error while calling endpoint." + Write-Host "Error while calling endpoint: $_" + Start-Sleep -Seconds 10 } }