Skip to content

feat: enhance output caching by adding VaryByQueryKeys for Category a… #65

feat: enhance output caching by adding VaryByQueryKeys for Category a…

feat: enhance output caching by adding VaryByQueryKeys for Category a… #65

Workflow file for this run

name: Build and Deploy
# Run when commits are pushed to main (excluding Content folder changes)
on:
workflow_dispatch:
push:
# Run when commits are pushed to mainline branch (main or master)
# Set this to the mainline branch you are using
branches:
- main
# Exclude Content folder changes to avoid unnecessary deployments
paths-ignore:
- 'Content/**'
- '.github/**'
- 'docs/*'
# Set up permissions for deploying with secretless Azure federated credentials
# https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux#set-up-azure-login-with-openid-connect-authentication
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
env:
AZURE_CLIENT_ID: ${{ vars.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ vars.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ vars.AZURE_SUBSCRIPTION_ID }}
AZURE_ENV_NAME: ${{ vars.AZURE_ENV_NAME }}
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
CACHE_REFRESH_API_KEY: ${{ secrets.CACHE_REFRESH_API_KEY }}
AZURE_REDIS: ${{ secrets.AZURE_REDIS }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install azd
uses: Azure/setup-azd@v2
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
9.x.x
- name: Run Unit Tests
run: dotnet test --verbosity normal
if: always()
- name: Log in with Azure (Federated Credentials)
run: |
azd auth login `
--client-id "$Env:AZURE_CLIENT_ID" `
--federated-credential-provider "github" `
--tenant-id "$Env:AZURE_TENANT_ID"
shell: pwsh
- name: Provision Infrastructure
run: azd provision --no-prompt
- name: Deploy Application
run: azd deploy --no-prompt
- name: Refresh Web App Cache
if: success()
run: |
echo "Refreshing web application cache..."
# Wait a moment for the deployment to fully complete
sleep 5
# Call the cache refresh endpoint with API key authentication
response=$(curl -s -w "%{http_code}" -X POST "https://copilotthatjawn.com/api/cache/refresh" \
-H "X-API-Key: ${{ secrets.CACHE_REFRESH_API_KEY }}" \
-o /tmp/cache_response.json)
if [ "$response" = "200" ]; then
echo "Cache refresh successful"
cat /tmp/cache_response.json
else
echo "Cache refresh failed with HTTP status: $response"
cat /tmp/cache_response.json || echo "No response body"
# Don't fail the workflow if cache refresh fails - it's not critical
echo "Continuing workflow despite cache refresh failure..."
fi