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",
|
IconName = "Broom",
|
||||||
IconVariant = IconVariant.Filled,
|
IconVariant = IconVariant.Filled,
|
||||||
UpdateState = ctx =>
|
UpdateState = commandStateContext =>
|
||||||
ctx.ResourceSnapshot.HealthStatus == HealthStatus.Healthy
|
commandStateContext.ResourceSnapshot.HealthStatus == HealthStatus.Healthy
|
||||||
? ResourceCommandState.Enabled
|
? ResourceCommandState.Enabled
|
||||||
: ResourceCommandState.Disabled
|
: ResourceCommandState.Disabled
|
||||||
};
|
};
|
||||||
@@ -31,12 +31,12 @@ public static class RedisResourceBuilderExtensions
|
|||||||
private static async Task<ExecuteCommandResult> RunAsync(
|
private static async Task<ExecuteCommandResult> RunAsync(
|
||||||
IResourceBuilder<RedisResource> builder)
|
IResourceBuilder<RedisResource> builder)
|
||||||
{
|
{
|
||||||
var connStr = await builder.Resource.GetConnectionStringAsync()
|
var connectionString = await builder.Resource.GetConnectionStringAsync()
|
||||||
?? throw new InvalidOperationException(
|
?? throw new InvalidOperationException(
|
||||||
"Could not resolve Redis connection string.");
|
"Could not resolve Redis connection string.");
|
||||||
|
|
||||||
await using var mux = await ConnectionMultiplexer.ConnectAsync(connStr);
|
await using var multiplexer = await ConnectionMultiplexer.ConnectAsync(connectionString);
|
||||||
var db = mux.GetDatabase();
|
var db = multiplexer.GetDatabase();
|
||||||
|
|
||||||
// Clear everything across all DBs. Prefer FLUSHDB if you only want the current DB.
|
// Clear everything across all DBs. Prefer FLUSHDB if you only want the current DB.
|
||||||
await db.ExecuteAsync("FLUSHALL");
|
await db.ExecuteAsync("FLUSHALL");
|
||||||
|
|||||||
Reference in New Issue
Block a user