Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ name: "CodeQL"
on:
push:
branches: [ "main" ]
aths-ignore:
- ".github/workflows/deploy/**"
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
paths-ignore:
- ".github/workflows/deploy/**"
schedule:
- cron: '0 0 * * 1'

Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/deploy/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
USE_IN_MEMORY_DATABASE=<true_or_false>
ASPNETCORE_ENVIRONMENT=Development
ASPNETCORE_URLS=http://+:80;https://+:443
ASPNETCORE_HTTP_PORTS=80
ASPNETCORE_HTTPS_PORTS=443
APP_URL=<your_app_url>
APP_VERSION=<your_app_version>

DB_PROVIDER=mssql
DB_CONNECTION_STRING=Server=<your_server>;Database=<your_db>;User Id=<your_user>;Password=<your_password>;MultipleActiveResultSets=true;Encrypt=false;TrustServerCertificate=false
SA_PASSWORD=<your_sa_password>

SMTP_USER=<your_smtp_user>
SMTP_PORT=2525
SMTP_SERVER=<your_smtp_server>
SMTP_PASSWORD=<your_smtp_password>
SMTP_DEFAULT_FROM=<your_smtp_from_email>

MS_CLIENT_ID=<your_microsoft_client_id>
MS_CLIENT_SECRET=<your_microsoft_client_secret>

GOOGLE_CLIENT_ID=<your_google_client_id>
GOOGLE_CLIENT_SECRET=<your_google_client_secret>

FB_APP_ID=<your_facebook_app_id>
FB_APP_SECRET=<your_facebook_app_secret>

MINIO_ENDPOINT=<your_minio_endpoint>
MINIO_ACCESS_KEY=<your_minio_access_key>
MINIO_SECRET_KEY=<your_minio_secret_key>
MINIO_BUCKET=<your_minio_bucket>
53 changes: 53 additions & 0 deletions .github/workflows/deploy/docker-compose-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: '3.8'
services:
mssql:
image: mcr.microsoft.com/mssql/server:2019-latest
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=${SA_PASSWORD} # 请在 .env 中配置你的 SA 密码
ports:
- "1433:1433"
volumes:
- mssql_data:/var/opt/mssql
healthcheck:
test: ["CMD-SHELL", "/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P ${SA_PASSWORD} -Q \"SELECT 1\""]
interval: 10s
timeout: 10s
retries: 3

blazorserverapp:
image: blazordevlab/cleanarchitectureblazorserver:1.1.95-pre.c66e9603
environment:
- UseInMemoryDatabase=${USE_IN_MEMORY_DATABASE}
- ASPNETCORE_ENVIRONMENT=${ASPNETCORE_ENVIRONMENT}
- ASPNETCORE_URLS=${ASPNETCORE_URLS}
- ASPNETCORE_HTTP_PORTS=${ASPNETCORE_HTTP_PORTS}
- ASPNETCORE_HTTPS_PORTS=${ASPNETCORE_HTTPS_PORTS}
- AppConfigurationSettings__ApplicationUrl=${APP_URL}
- AppConfigurationSettings__Version=${APP_VERSION}
- DatabaseSettings__DBProvider=mssql
- DatabaseSettings__ConnectionString=Server=mssql;Database=BlazorDashboardDb;User Id=sa;Password=${SA_PASSWORD};MultipleActiveResultSets=true;Encrypt=false;TrustServerCertificate=false
- SmtpClientOptions__User=${SMTP_USER}
- SmtpClientOptions__Port=${SMTP_PORT}
- SmtpClientOptions__Server=${SMTP_SERVER}
- SmtpClientOptions__Password=${SMTP_PASSWORD}
- SmtpClientOptions__DefaultFromEmail=${SMTP_DEFAULT_FROM}
- Authentication__Microsoft__ClientId=${MS_CLIENT_ID}
- Authentication__Microsoft__ClientSecret=${MS_CLIENT_SECRET}
- Authentication__Google__ClientId=${GOOGLE_CLIENT_ID}
- Authentication__Google__ClientSecret=${GOOGLE_CLIENT_SECRET}
- Authentication__Facebook__AppId=${FB_APP_ID}
- Authentication__Facebook__AppSecret=${FB_APP_SECRET}
- Minio__Endpoint=${MINIO_ENDPOINT}
- Minio__AccessKey=${MINIO_ACCESS_KEY}
- Minio__SecretKey=${MINIO_SECRET_KEY}
- Minio__BucketName=${MINIO_BUCKET}
ports:
- "8014:80"
- "8015:443"
depends_on:
mssql:
condition: service_healthy

volumes:
mssql_data:
32 changes: 32 additions & 0 deletions .github/workflows/deploy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: '3.8'
services:
blazorserverapp:
image: blazordevlab/cleanarchitectureblazorserver:1.1.95-pre.c66e9603
environment:
- UseInMemoryDatabase=${USE_IN_MEMORY_DATABASE}
- ASPNETCORE_ENVIRONMENT=${ASPNETCORE_ENVIRONMENT}
- ASPNETCORE_URLS=${ASPNETCORE_URLS}
- ASPNETCORE_HTTP_PORTS=${ASPNETCORE_HTTP_PORTS}
- ASPNETCORE_HTTPS_PORTS=${ASPNETCORE_HTTPS_PORTS}
- AppConfigurationSettings__ApplicationUrl=${APP_URL}
- AppConfigurationSettings__Version=${APP_VERSION}
- DatabaseSettings__DBProvider=${DB_PROVIDER}
- DatabaseSettings__ConnectionString=${DB_CONNECTION_STRING}
- SmtpClientOptions__User=${SMTP_USER}
- SmtpClientOptions__Port=${SMTP_PORT}
- SmtpClientOptions__Server=${SMTP_SERVER}
- SmtpClientOptions__Password=${SMTP_PASSWORD}
- SmtpClientOptions__DefaultFromEmail=${SMTP_DEFAULT_FROM}
- Authentication__Microsoft__ClientId=${MS_CLIENT_ID}
- Authentication__Microsoft__ClientSecret=${MS_CLIENT_SECRET}
- Authentication__Google__ClientId=${GOOGLE_CLIENT_ID}
- Authentication__Google__ClientSecret=${GOOGLE_CLIENT_SECRET}
- Authentication__Facebook__AppId=${FB_APP_ID}
- Authentication__Facebook__AppSecret=${FB_APP_SECRET}
- Minio__Endpoint=${MINIO_ENDPOINT}
- Minio__AccessKey=${MINIO_ACCESS_KEY}
- Minio__SecretKey=${MINIO_SECRET_KEY}
- Minio__BucketName=${MINIO_BUCKET}
ports:
- "8014:80"
- "8015:443"
64 changes: 47 additions & 17 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ name: Docker Image CI
on:
push:
branches: [ "main" ]
paths-ignore:
- ".github/workflows/deploy/**"
pull_request:
branches: [ "main" ]
paths-ignore:
- ".github/workflows/deploy/**"

jobs:

Expand All @@ -26,25 +30,51 @@ jobs:
- run: git tag ${{ steps.version.outputs.version }}
- run: git push origin ${{ steps.version.outputs.version }}

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}



- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: blazordevlab/cleanarchitectureblazorserver:${{ steps.version.outputs.version }}
# - name: Build and push
# uses: docker/build-push-action@v5
# with:
# context: .
# push: true
# tags: blazordevlab/cleanarchitectureblazorserver:${{ steps.version.outputs.version }}

- name: Build and push with latest tag
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: blazordevlab/cleanarchitectureblazorserver:latest
# - name: Build and push with latest tag
# uses: docker/build-push-action@v5
# with:
# context: .
# push: true
# tags: blazordevlab/cleanarchitectureblazorserver:latest

# - name: Update version in docker-compose files
# run: |
# echo "Updating docker-compose files with version ${{ steps.version.outputs.version }}"
# sed -i 's#\(blazordevlab/cleanarchitectureblazorserver:\).*#\1${{ steps.version.outputs.version }}#' .github/workflows/deploy/docker-compose.yml
# sed -i 's#\(blazordevlab/cleanarchitectureblazorserver:\).*#\1${{ steps.version.outputs.version }}#' .github/workflows/deploy/docker-compose-db.yml

- name: Update version in docker-compose files
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
echo "Updating docker-compose files with version ${{ steps.version.outputs.version }}"
sed -i 's#\(blazordevlab/cleanarchitectureblazorserver:\).*#\1${{ steps.version.outputs.version }}#' .github/workflows/deploy/docker-compose.yml
sed -i 's#\(blazordevlab/cleanarchitectureblazorserver:\).*#\1${{ steps.version.outputs.version }}#' .github/workflows/deploy/docker-compose-db.yml

- name: Set up Git
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"

- name: Commit and push updated files
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
git add .github/workflows/deploy/docker-compose.yml .github/workflows/deploy/docker-compose-db.yml
git commit -m "Update Docker Compose files to version ${{ steps.version.outputs.version }}"
git push origin main

4 changes: 4 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ name: Build
on:
push:
branches: [ main ]
paths-ignore:
- ".github/workflows/deploy/**"
pull_request:
branches: [ main ]
paths-ignore:
- ".github/workflows/deploy/**"

jobs:
build:
Expand Down
32 changes: 20 additions & 12 deletions src/Application/Common/Models/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,30 @@ protected Result(bool succeeded, IEnumerable<string>? errors, T? data)
public static new Task<Result<T>> FailureAsync(params string[] errors) => Task.FromResult(Failure(errors));

/// <summary>
/// Executes the appropriate function based on whether the operation succeeded.
/// Executes the appropriate action based on whether the operation succeeded.
/// </summary>
/// <typeparam name="TResult">The return type.</typeparam>
/// <param name="onSuccess">Function to execute if the operation succeeded, with the data.</param>
/// <param name="onFailure">Function to execute if the operation failed, with an error message.</param>
public TResult Match<TResult>(Func<T, TResult> onSuccess, Func<string, TResult> onFailure)
=> Succeeded ? onSuccess(Data!) : onFailure(ErrorMessage);
/// <param name="onSuccess">Action to execute if the operation succeeded, with the data.</param>
/// <param name="onFailure">Action to execute if the operation failed, with an error message.</param>
public void Match(Action<T> onSuccess, Action<string> onFailure)
{
if (Succeeded)
onSuccess(Data!);
else
onFailure(ErrorMessage);
}

/// <summary>
/// Asynchronously executes the appropriate function based on whether the operation succeeded.
/// Asynchronously executes the appropriate action based on whether the operation succeeded.
/// </summary>
/// <typeparam name="TResult">The return type.</typeparam>
/// <param name="onSuccess">Asynchronous function to execute if the operation succeeded, with the data.</param>
/// <param name="onFailure">Asynchronous function to execute if the operation failed, with an error message.</param>
public Task<TResult> MatchAsync<TResult>(Func<T, Task<TResult>> onSuccess, Func<string, Task<TResult>> onFailure)
=> Succeeded ? onSuccess(Data!) : onFailure(ErrorMessage);
/// <param name="onSuccess">Asynchronous action to execute if the operation succeeded, with the data.</param>
/// <param name="onFailure">Asynchronous action to execute if the operation failed, with an error message.</param>
public async Task MatchAsync(Func<T, Task> onSuccess, Func<string, Task> onFailure)
{
if (Succeeded)
await onSuccess(Data!);
else
await onFailure(ErrorMessage);
}

/// <summary>
/// Maps the data contained in the result to a new type.
Expand Down
4 changes: 1 addition & 3 deletions src/Application/Common/Models/UploadRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@ namespace CleanArchitecture.Blazor.Application.Common.Models;

public class UploadRequest
{
public UploadRequest(string fileName, UploadType uploadType, byte[] data, bool overwrite = false,string? folder=null, ResizeOptions? resizeOptions=null)
public UploadRequest(string fileName, UploadType uploadType, byte[] data, bool overwrite = false,string? folder=null)
{
FileName = fileName;
UploadType = uploadType;
Data = data;
Overwrite = overwrite;
Folder = folder;
ResizeOptions = resizeOptions;
}
public string FileName { get; set; }
public string? Extension { get; set; }
public UploadType UploadType { get; set; }
public bool Overwrite { get; set; }
public byte[] Data { get; set; }
public string? Folder { get; set; }
public ResizeOptions? ResizeOptions { get; set; }
}
Loading
Loading