mirror of
https://github.com/fiodarsazanavets/aspire-13-examples.git
synced 2026-08-04 09:48:50 +00:00
Improved naming and added a sample of GitHub action pipeline
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
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
|
||||
|
||||
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 }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Make sure the right .NET SDK is available
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '10.0.x'
|
||||
|
||||
- name: Install azd
|
||||
uses: Azure/setup-azd@v1.0.0
|
||||
|
||||
- name: Install .NET Aspire workload
|
||||
run: dotnet workload install aspire
|
||||
|
||||
# ---------- CI: build & test ----------
|
||||
- name: Restore
|
||||
run: dotnet restore ./AspireApp.sln
|
||||
|
||||
- name: Build
|
||||
run: dotnet build ./AspireApp.sln --configuration Release --no-restore
|
||||
|
||||
- name: Test
|
||||
run: dotnet test ./AspireApp.sln --configuration Release --no-build
|
||||
# If tests fail here, the job stops and nothing below runs
|
||||
# --------------------------------------
|
||||
|
||||
- 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
|
||||
env:
|
||||
AZD_INITIAL_ENVIRONMENT_CONFIG: ${{ secrets.AZD_INITIAL_ENVIRONMENT_CONFIG }}
|
||||
|
||||
- name: Deploy Application
|
||||
run: azd deploy --no-prompt
|
||||
|
||||
+5
-5
@@ -12,8 +12,8 @@ public static class RedisResourceBuilderExtensions
|
||||
{
|
||||
IconName = "Broom",
|
||||
IconVariant = IconVariant.Filled,
|
||||
UpdateState = ctx =>
|
||||
ctx.ResourceSnapshot.HealthStatus == HealthStatus.Healthy
|
||||
UpdateState = commandStateContext =>
|
||||
commandStateContext.ResourceSnapshot.HealthStatus == HealthStatus.Healthy
|
||||
? ResourceCommandState.Enabled
|
||||
: ResourceCommandState.Disabled
|
||||
};
|
||||
@@ -31,12 +31,12 @@ public static class RedisResourceBuilderExtensions
|
||||
private static async Task<ExecuteCommandResult> RunAsync(
|
||||
IResourceBuilder<RedisResource> builder)
|
||||
{
|
||||
var connStr = await builder.Resource.GetConnectionStringAsync()
|
||||
var connectionString = await builder.Resource.GetConnectionStringAsync()
|
||||
?? throw new InvalidOperationException(
|
||||
"Could not resolve Redis connection string.");
|
||||
|
||||
await using var mux = await ConnectionMultiplexer.ConnectAsync(connStr);
|
||||
var db = mux.GetDatabase();
|
||||
await using var multiplexer = await ConnectionMultiplexer.ConnectAsync(connectionString);
|
||||
var db = multiplexer.GetDatabase();
|
||||
|
||||
// Clear everything across all DBs. Prefer FLUSHDB if you only want the current DB.
|
||||
await db.ExecuteAsync("FLUSHALL");
|
||||
|
||||
Reference in New Issue
Block a user