Skip to content

Refactor user caching system; add Copilot license support #9

Refactor user caching system; add Copilot license support

Refactor user caching system; add Copilot license support #9

Workflow file for this run

name: Build and Deploy to Azure
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
permissions:
id-token: write
contents: read
env:
DOTNET_VERSION: '10.0.x'
AZURE_WEBAPP_PACKAGE_PATH: './publish'
SOLUTION_PATH: 'src/Full/Bot/Adoption Bot.sln'
WORKING_DIRECTORY: 'src/Full/Bot'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Node dependencies
working-directory: ${{ env.WORKING_DIRECTORY }}/Web/web.client
run: npm ci
- name: Build Node client
working-directory: ${{ env.WORKING_DIRECTORY }}/Web/web.client
run: npm run build
- name: Restore dependencies
run: dotnet restore "${{ env.SOLUTION_PATH }}"
- name: Create test appsettings.json from secret
if: ${{ env.HAS_TESTS_CONFIG == 'true' }}
working-directory: ${{ env.WORKING_DIRECTORY }}/UnitTests
env:
TESTS_APPSETTINGS_JSON: ${{ secrets.TESTS_APPSETTINGS_JSON }}
run: echo "$TESTS_APPSETTINGS_JSON" > appsettings.json
- name: Build solution
run: dotnet build "${{ env.SOLUTION_PATH }}" --configuration Release --no-restore
- name: Run unit tests
if: ${{ env.HAS_TESTS_CONFIG == 'true' }}
run: dotnet test "${{ env.SOLUTION_PATH }}" --configuration Release --no-build --verbosity normal --logger trx --results-directory TestResults
- name: Skip tests notification
if: ${{ env.HAS_TESTS_CONFIG != 'true' }}
run: echo "::warning::Tests skipped - TESTS_APPSETTINGS_JSON secret not configured"
- name: Upload test results
uses: actions/upload-artifact@v4
if: ${{ always() && env.HAS_TESTS_CONFIG == 'true' }}
with:
name: test-results
path: TestResults
- name: Publish Web.Server
run: dotnet publish "${{ env.WORKING_DIRECTORY }}/Web/Web.Server/Web.Server.csproj" --configuration Release --output ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: Upload artifact for deployment
uses: actions/upload-artifact@v4
with:
name: webapp-package
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
env:
HAS_TESTS_CONFIG: ${{ secrets.TESTS_APPSETTINGS_JSON != '' }}
deploy:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
environment:
name: 'Production'
url: ${{ steps.deploy-to-azure.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: webapp-package
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Deploy to Azure Web App
id: deploy-to-azure
uses: azure/webapps-deploy@v3
with:
app-name: ${{ vars.AZURE_WEBAPP_NAME }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
- name: Azure logout
run: az logout
if: always()