update actions yaml
This commit is contained in:
parent
831165147f
commit
8a48123dd7
39
.gitea/workflows/deploy-k8s.yaml
Normal file
39
.gitea/workflows/deploy-k8s.yaml
Normal file
@ -0,0 +1,39 @@
|
||||
name: dotnet-publish-nuget
|
||||
on: [push]
|
||||
|
||||
env:
|
||||
DOTNET_VERSION: 8.x
|
||||
DOTNET_NUGET_SOURCE_URL: https://git.mworkspace.cn/api/packages/GiteaActionsSample/nuget/index.json
|
||||
jobs:
|
||||
Pack-And-Publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: List files in the repos
|
||||
run: ls ${{ gitea.workspace }} && ls $GITEA_WORKSPACE
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||||
cache: true
|
||||
source-url: ${{ env.DOTNET_NUGET_SOURCE_URL }}
|
||||
env:
|
||||
NUGET_AUTH_TOKEN: ${{secrets.NUGET_APIKEY}}
|
||||
- name: Install dependencies
|
||||
run: dotnet restore -s https://api.nuget.org/v3/index.json
|
||||
- name: Build
|
||||
run: dotnet build --configuration Release --no-restore -o dst
|
||||
- name: Test
|
||||
run: dotnet test --no-restore --verbosity normal
|
||||
- name: Login to Aliyun Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: registry.cn-guangzhou.aliyuncs.com
|
||||
username: ${{ secrets.DOCKERHUB_NROP_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_NROP_PASSWORD }}
|
||||
- name: Build docker image and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
tags: [acme_nrop/dotnet-deploy-k8s:latest, acme_nrop/dotnet-deploy-k8s:${{ gitea.sha }}]
|
||||
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@ -0,0 +1,8 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY dst .
|
||||
EXPOSE 80
|
||||
|
||||
ENTRYPOINT ["dotnet", "dotnet-deploy-k8s.dll"]
|
||||
42
Program.cs
Normal file
42
Program.cs
Normal file
@ -0,0 +1,42 @@
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
}
|
||||
|
||||
var summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
app.MapGet("/weatherforecast", () =>
|
||||
{
|
||||
var forecast = Enumerable.Range(1, 5).Select(index =>
|
||||
new WeatherForecast
|
||||
(
|
||||
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
Random.Shared.Next(-20, 55),
|
||||
summaries[Random.Shared.Next(summaries.Length)]
|
||||
))
|
||||
.ToArray();
|
||||
return forecast;
|
||||
})
|
||||
.WithName("GetWeatherForecast")
|
||||
.WithOpenApi();
|
||||
|
||||
app.Run();
|
||||
|
||||
record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
|
||||
{
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
}
|
||||
31
Properties/launchSettings.json
Normal file
31
Properties/launchSettings.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:8434",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "http://localhost:5022",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
8
appsettings.Development.json
Normal file
8
appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
9
appsettings.json
Normal file
9
appsettings.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
15
dotnet-deploy-k8s.csproj
Normal file
15
dotnet-deploy-k8s.csproj
Normal file
@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>dotnet_deploy_k8s</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
6
dotnet-deploy-k8s.http
Normal file
6
dotnet-deploy-k8s.http
Normal file
@ -0,0 +1,6 @@
|
||||
@dotnet_deploy_k8s_HostAddress = http://localhost:5022
|
||||
|
||||
GET {{dotnet_deploy_k8s_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
Loading…
x
Reference in New Issue
Block a user