Update Program.cs #43
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: "Deploy to Azure" | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- release | |
paths: | |
- 'DevCraftAspire.ApiService/**/*' | |
- 'DevCraftAspire.AppHost/**/*' | |
- 'DevCraftAspire.ServiceDefaults/**/*' | |
- 'DevCraftAspire.Web/**/*' | |
- '.github/workflows/deploy.yml' | |
env: | |
CONTAINER_REGISTRY: "ghcr.io" | |
BASE_IMAGE: "ghcr.io/lancemccarthy/aspirebase:8.0" | |
APP_IMAGE_NAME: lancemccarthy/aspireapiservice | |
APP_IMAGE_TAG: "8.0" | |
ASPIRE_ENVIRONMENT: "aspire2b" | |
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}} | |
AZURE_CREDS_PROVIDER: "github" | |
permissions: | |
id-token: write | |
contents: read | |
packages: write | |
jobs: | |
# ## Not needed on every build anymore, the monitor-images.yml workflow will check and rebuild base image as-needed ## | |
# update_base_image: | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Checkout | |
# uses: actions/checkout@v4 | |
# with: | |
# fetch-depth: 0 | |
# - name: Login to ghcr.io | |
# uses: docker/login-action@v3 | |
# with: | |
# registry: ${{env.CONTAINER_REGISTRY}} | |
# username: ${{github.actor}} | |
# password: ${{secrets.GITHUB_TOKEN}} | |
# Build a custom base image with needed Linux dependencies preinstalled | |
# - name: Build Custom Image and push to GitHub packages | |
# working-directory: '.dockerbuilds/baseimage' | |
# run: | | |
# docker build -t ${{ env.BASE_IMAGE }} -f Dockerfile . | |
# docker push ${{ env.BASE_IMAGE }} | |
deploy_app: | |
#needs: [update_base_image] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install .NET Aspire workload | |
run: dotnet workload install aspire --ignore-failed-sources | |
- name: Login to ghcr.io | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{env.CONTAINER_REGISTRY}} | |
username: ${{github.actor}} | |
password: ${{secrets.GITHUB_TOKEN}} | |
- name: Update nuget credentials | |
run: dotnet nuget update source "TelerikServer" -s "https://nuget.telerik.com/v3/index.json" -u 'api-key' -p ${{secrets.TELERIK_NUGET_KEY}} --store-password-in-clear-text | |
- name: Build container with custom base | |
run: dotnet publish 'DevCraftAspire.ApiService/DevCraftAspire.ApiService.csproj' /t:PublishContainer -p ContainerBaseImage="${{env.BASE_IMAGE}}" -p ContainerRepository="${{env.APP_IMAGE_NAME}}" -p ContainerImageTag="${{env.APP_IMAGE_TAG}}" -p ContainerRegistry="${{env.CONTAINER_REGISTRY}}" | |
- name: Install azd | |
uses: Azure/[email protected] | |
- name: Log into Azure with GitHub Federated Credentials (OpenID) | |
shell: pwsh | |
run: azd auth login --client-id "${{env.AZURE_CLIENT_ID}}" --tenant-id "${{env.AZURE_TENANT_ID}}" --federated-credential-provider "${{env.AZURE_CREDS_PROVIDER}}" | |
- name: Provision Infrastructure | |
shell: pwsh | |
run: azd provision --no-prompt --environment "${{env.ASPIRE_ENVIRONMENT}}" | |
- name: Deploy Application | |
shell: pwsh | |
run: azd deploy --no-prompt --environment "${{env.ASPIRE_ENVIRONMENT}}" |