From b1a243a030c22bd1c093118fd4c37e4831a173db Mon Sep 17 00:00:00 2001 From: stre4m Date: Sun, 8 Sep 2024 18:49:52 +0500 Subject: [PATCH 1/2] =?UTF-8?q?hw-docker-compose:=20=D1=81=D0=BE=D0=B7?= =?UTF-8?q?=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=B8=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20docker-compose=20=D1=81=20post?= =?UTF-8?q?gre=20sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- Domain/Domain.Entities/Lesson.cs | 2 +- .../DatabaseContext.cs | 2 +- .../EntityFrameworkInstaller.cs | 4 +- .../Infrastructure.EntityFramework.csproj | 1 + ....cs => 20240908134618_Initial.Designer.cs} | 29 ++++-- ...1_Initial.cs => 20240908134618_Initial.cs} | 21 ++-- .../20240908134835_AddedDateTime.Designer.cs | 97 +++++++++++++++++++ .../20240908134835_AddedDateTime.cs | 30 ++++++ .../DatabaseContextModelSnapshot.cs | 35 ++++--- .../Lesson/CreatingLessonDto.cs | 6 +- .../Services.Contracts/Lesson/LessonDto.cs | 6 +- .../Lesson/UpdatingLessonDto.cs | 6 +- WebApi/Models/Lesson/CreatingLessonModel.cs | 6 +- WebApi/Models/Lesson/LessonModel.cs | 6 +- WebApi/Models/Lesson/UpdatingLessonModel.cs | 6 +- WebApi/appsettings.json | 4 +- docker-compose.yml | 28 ++++++ 18 files changed, 247 insertions(+), 44 deletions(-) rename Infrastructure/Infrastructure.EntityFramework/Migrations/{20240320161651_Initial.Designer.cs => 20240908134618_Initial.Designer.cs} (68%) rename Infrastructure/Infrastructure.EntityFramework/Migrations/{20240320161651_Initial.cs => 20240908134618_Initial.cs} (64%) create mode 100644 Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134835_AddedDateTime.Designer.cs create mode 100644 Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134835_AddedDateTime.cs create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile index 70f7c6e..da47e33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ COPY ["Services/Services.Contracts/Services.Contracts.csproj", "Services/Service COPY ["Services/Services.Abstractions/Services.Abstractions.csproj", "Services/Services.Abstractions/"] COPY ["Services/Services.Implementations/Services.Implementations.csproj", "Services/Services.Implementations/"] RUN dotnet restore "WebApi/WebApi.csproj" -COPY ../ . +COPY . . WORKDIR "/src/WebApi" RUN dotnet build "WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/build diff --git a/Domain/Domain.Entities/Lesson.cs b/Domain/Domain.Entities/Lesson.cs index 2b08660..2ca7659 100644 --- a/Domain/Domain.Entities/Lesson.cs +++ b/Domain/Domain.Entities/Lesson.cs @@ -30,6 +30,6 @@ public class Lesson: IEntity /// public bool Deleted { get; set; } - //public DateTime DateTime { get; set; } + public DateTime DateTime { get; set; } } } \ No newline at end of file diff --git a/Infrastructure/Infrastructure.EntityFramework/DatabaseContext.cs b/Infrastructure/Infrastructure.EntityFramework/DatabaseContext.cs index db8b529..a6f621b 100644 --- a/Infrastructure/Infrastructure.EntityFramework/DatabaseContext.cs +++ b/Infrastructure/Infrastructure.EntityFramework/DatabaseContext.cs @@ -26,7 +26,7 @@ public DatabaseContext(DbContextOptions options) : base(options protected override void OnModelCreating(ModelBuilder modelBuilder) { - base.OnModelCreating(modelBuilder); + base.OnModelCreating(modelBuilder); modelBuilder.Entity() .HasMany(u => u.Lessons) diff --git a/Infrastructure/Infrastructure.EntityFramework/EntityFrameworkInstaller.cs b/Infrastructure/Infrastructure.EntityFramework/EntityFrameworkInstaller.cs index f39f300..2a2b1a4 100644 --- a/Infrastructure/Infrastructure.EntityFramework/EntityFrameworkInstaller.cs +++ b/Infrastructure/Infrastructure.EntityFramework/EntityFrameworkInstaller.cs @@ -12,8 +12,8 @@ public static IServiceCollection ConfigureContext(this IServiceCollection servic services.AddDbContext(optionsBuilder => optionsBuilder //.UseLazyLoadingProxies() // lazy loading - //.UseNpgsql(connectionString)); - .UseSqlite(connectionString)); + .UseNpgsql(connectionString)); + //.UseSqlite(connectionString)); //.UseSqlServer(connectionString)); #region health checks diff --git a/Infrastructure/Infrastructure.EntityFramework/Infrastructure.EntityFramework.csproj b/Infrastructure/Infrastructure.EntityFramework/Infrastructure.EntityFramework.csproj index da37366..4b4218b 100644 --- a/Infrastructure/Infrastructure.EntityFramework/Infrastructure.EntityFramework.csproj +++ b/Infrastructure/Infrastructure.EntityFramework/Infrastructure.EntityFramework.csproj @@ -40,6 +40,7 @@ + diff --git a/Infrastructure/Infrastructure.EntityFramework/Migrations/20240320161651_Initial.Designer.cs b/Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134618_Initial.Designer.cs similarity index 68% rename from Infrastructure/Infrastructure.EntityFramework/Migrations/20240320161651_Initial.Designer.cs rename to Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134618_Initial.Designer.cs index a5c0ad9..20d9972 100644 --- a/Infrastructure/Infrastructure.EntityFramework/Migrations/20240320161651_Initial.Designer.cs +++ b/Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134618_Initial.Designer.cs @@ -4,36 +4,43 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Infrastructure.EntityFramework.Migrations { [DbContext(typeof(DatabaseContext))] - [Migration("20240320161651_Initial")] + [Migration("20240908134618_Initial")] partial class Initial { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.0"); + modelBuilder + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("Domain.Entities.Course", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Deleted") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("Name") .HasMaxLength(100) - .HasColumnType("TEXT"); + .HasColumnType("character varying(100)"); b.Property("Price") - .HasColumnType("TEXT"); + .HasColumnType("numeric"); b.HasKey("Id"); @@ -44,17 +51,19 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("CourseId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("Deleted") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("Subject") .HasMaxLength(100) - .HasColumnType("TEXT"); + .HasColumnType("character varying(100)"); b.HasKey("Id"); diff --git a/Infrastructure/Infrastructure.EntityFramework/Migrations/20240320161651_Initial.cs b/Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134618_Initial.cs similarity index 64% rename from Infrastructure/Infrastructure.EntityFramework/Migrations/20240320161651_Initial.cs rename to Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134618_Initial.cs index 721e9f9..e29c15b 100644 --- a/Infrastructure/Infrastructure.EntityFramework/Migrations/20240320161651_Initial.cs +++ b/Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134618_Initial.cs @@ -1,4 +1,5 @@ using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -14,11 +15,11 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "Courses", columns: table => new { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Name = table.Column(type: "TEXT", maxLength: 100, nullable: true), - Price = table.Column(type: "TEXT", nullable: false), - Deleted = table.Column(type: "INTEGER", nullable: false) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Name = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), + Price = table.Column(type: "numeric", nullable: false), + Deleted = table.Column(type: "boolean", nullable: false) }, constraints: table => { @@ -29,11 +30,11 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "Lessons", columns: table => new { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Subject = table.Column(type: "TEXT", maxLength: 100, nullable: true), - CourseId = table.Column(type: "INTEGER", nullable: false), - Deleted = table.Column(type: "INTEGER", nullable: false) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Subject = table.Column(type: "character varying(100)", maxLength: 100, nullable: true), + CourseId = table.Column(type: "integer", nullable: false), + Deleted = table.Column(type: "boolean", nullable: false) }, constraints: table => { diff --git a/Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134835_AddedDateTime.Designer.cs b/Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134835_AddedDateTime.Designer.cs new file mode 100644 index 0000000..262b790 --- /dev/null +++ b/Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134835_AddedDateTime.Designer.cs @@ -0,0 +1,97 @@ +// +using System; +using Infrastructure.EntityFramework; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Infrastructure.EntityFramework.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20240908134835_AddedDateTime")] + partial class AddedDateTime + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Domain.Entities.Course", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Deleted") + .HasColumnType("boolean"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Price") + .HasColumnType("numeric"); + + b.HasKey("Id"); + + b.ToTable("Courses"); + }); + + modelBuilder.Entity("Domain.Entities.Lesson", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CourseId") + .HasColumnType("integer"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Deleted") + .HasColumnType("boolean"); + + b.Property("Subject") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.HasIndex("CourseId"); + + b.ToTable("Lessons"); + }); + + modelBuilder.Entity("Domain.Entities.Lesson", b => + { + b.HasOne("Domain.Entities.Course", "Course") + .WithMany("Lessons") + .HasForeignKey("CourseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Course"); + }); + + modelBuilder.Entity("Domain.Entities.Course", b => + { + b.Navigation("Lessons"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134835_AddedDateTime.cs b/Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134835_AddedDateTime.cs new file mode 100644 index 0000000..9cc6cad --- /dev/null +++ b/Infrastructure/Infrastructure.EntityFramework/Migrations/20240908134835_AddedDateTime.cs @@ -0,0 +1,30 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Infrastructure.EntityFramework.Migrations +{ + /// + public partial class AddedDateTime : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "DateTime", + table: "Lessons", + type: "timestamp with time zone", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "DateTime", + table: "Lessons"); + } + } +} diff --git a/Infrastructure/Infrastructure.EntityFramework/Migrations/DatabaseContextModelSnapshot.cs b/Infrastructure/Infrastructure.EntityFramework/Migrations/DatabaseContextModelSnapshot.cs index b7e3a71..91ddf48 100644 --- a/Infrastructure/Infrastructure.EntityFramework/Migrations/DatabaseContextModelSnapshot.cs +++ b/Infrastructure/Infrastructure.EntityFramework/Migrations/DatabaseContextModelSnapshot.cs @@ -1,8 +1,10 @@ // +using System; using Infrastructure.EntityFramework; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -14,50 +16,61 @@ partial class DatabaseContextModelSnapshot : ModelSnapshot protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.0"); + modelBuilder + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("Domain.Entities.Course", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Deleted") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("Name") .HasMaxLength(100) - .HasColumnType("TEXT"); + .HasColumnType("character varying(100)"); b.Property("Price") - .HasColumnType("TEXT"); + .HasColumnType("numeric"); b.HasKey("Id"); - b.ToTable("Courses", (string)null); + b.ToTable("Courses"); }); modelBuilder.Entity("Domain.Entities.Lesson", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("CourseId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone"); b.Property("Deleted") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("Subject") .HasMaxLength(100) - .HasColumnType("TEXT"); + .HasColumnType("character varying(100)"); b.HasKey("Id"); b.HasIndex("CourseId"); - b.ToTable("Lessons", (string)null); + b.ToTable("Lessons"); }); modelBuilder.Entity("Domain.Entities.Lesson", b => diff --git a/Services/Services.Contracts/Lesson/CreatingLessonDto.cs b/Services/Services.Contracts/Lesson/CreatingLessonDto.cs index ee5ae1e..1bdc9bd 100644 --- a/Services/Services.Contracts/Lesson/CreatingLessonDto.cs +++ b/Services/Services.Contracts/Lesson/CreatingLessonDto.cs @@ -1,4 +1,6 @@ -namespace Services.Contracts.Lesson +using System; + +namespace Services.Contracts.Lesson { /// /// ДТО урока. @@ -14,5 +16,7 @@ public class CreatingLessonDto /// Тема. /// public string Subject { get; set; } + + public DateTime DateTime { get; set; } } } \ No newline at end of file diff --git a/Services/Services.Contracts/Lesson/LessonDto.cs b/Services/Services.Contracts/Lesson/LessonDto.cs index bfb4e91..6e0f609 100644 --- a/Services/Services.Contracts/Lesson/LessonDto.cs +++ b/Services/Services.Contracts/Lesson/LessonDto.cs @@ -1,4 +1,6 @@ -namespace Services.Contracts.Lesson +using System; + +namespace Services.Contracts.Lesson { /// /// ДТО урока. @@ -14,5 +16,7 @@ public class LessonDto /// Тема. /// public string Subject { get; set; } + + public DateTime DateTime { get; set; } } } \ No newline at end of file diff --git a/Services/Services.Contracts/Lesson/UpdatingLessonDto.cs b/Services/Services.Contracts/Lesson/UpdatingLessonDto.cs index e1282c6..9a90827 100644 --- a/Services/Services.Contracts/Lesson/UpdatingLessonDto.cs +++ b/Services/Services.Contracts/Lesson/UpdatingLessonDto.cs @@ -1,4 +1,6 @@ -namespace Services.Contracts.Lesson +using System; + +namespace Services.Contracts.Lesson { /// /// ДТО редактируемого урока. @@ -9,5 +11,7 @@ public class UpdatingLessonDto /// Тема. /// public string Subject { get; set; } + + public DateTime DateTime { get; set; } } } \ No newline at end of file diff --git a/WebApi/Models/Lesson/CreatingLessonModel.cs b/WebApi/Models/Lesson/CreatingLessonModel.cs index 0f2ee6e..f6fdca7 100644 --- a/WebApi/Models/Lesson/CreatingLessonModel.cs +++ b/WebApi/Models/Lesson/CreatingLessonModel.cs @@ -1,4 +1,6 @@ -namespace WebApi.Models.Lesson +using System; + +namespace WebApi.Models.Lesson { public class CreatingLessonModel { @@ -11,5 +13,7 @@ public class CreatingLessonModel /// Тема. /// public string Subject { get; set; } + + public DateTime DateTime { get; set; } } } \ No newline at end of file diff --git a/WebApi/Models/Lesson/LessonModel.cs b/WebApi/Models/Lesson/LessonModel.cs index c325a55..d9dc4bb 100644 --- a/WebApi/Models/Lesson/LessonModel.cs +++ b/WebApi/Models/Lesson/LessonModel.cs @@ -1,4 +1,6 @@ -namespace WebApi.Models.Lesson +using System; + +namespace WebApi.Models.Lesson { public class LessonModel { @@ -11,5 +13,7 @@ public class LessonModel /// Тема. /// public string Subject { get; set; } + + public DateTime DateTime { get; set; } } } \ No newline at end of file diff --git a/WebApi/Models/Lesson/UpdatingLessonModel.cs b/WebApi/Models/Lesson/UpdatingLessonModel.cs index d85aeec..5586fcf 100644 --- a/WebApi/Models/Lesson/UpdatingLessonModel.cs +++ b/WebApi/Models/Lesson/UpdatingLessonModel.cs @@ -1,4 +1,6 @@ -namespace WebApi.Models.Lesson +using System; + +namespace WebApi.Models.Lesson { /// /// Модель редактируемого урока. @@ -9,5 +11,7 @@ public class UpdatingLessonModel /// Тема. /// public string Subject { get; set; } + + public DateTime DateTime { get; set; } } } \ No newline at end of file diff --git a/WebApi/appsettings.json b/WebApi/appsettings.json index 333575d..bff3e94 100644 --- a/WebApi/appsettings.json +++ b/WebApi/appsettings.json @@ -16,7 +16,7 @@ "AllowedHosts": "*", - "ConnectionString": "Data Source=../Infrastructure/LocalDatabase.db", - "ConnectionString2": "Host=localhost;Port=5432;Database=otus;UserId=postgres;Password=password", + "ConnectionString2": "Data Source=../Infrastructure/LocalDatabase.db", + "ConnectionString": "Host=localhost;Port=5432;Database=otus;UserId=postgres;Password=password", "ConnectionStringSQLServer": "Server=.\\MSSQL2008;Database=testDb;Trusted_Connection=True;" } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..13dfeb6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,28 @@ +services: + + postgres: + + image: postgres:14-alpine + restart: always + ports: + - 5432:5432 + volumes: + - pg-data:/var/lib/postgresql/data + environment: + - POSTGRES_PASSWORD=password + - POSTGRES_USER=postgres + - POSTGRES_DB=otus + + # web: + + # build: + # context: . + # dockerfile: Dockerfile + # ports: + # - "5101:5101" + # environment: + # "ASPNETCORE_ENVIRONMENT": "Development" + # "ASPNETCORE_URLS": "http://+:5100" + +volumes: + pg-data: \ No newline at end of file From b77833d32131ad11e05615f6c6762dab3c902815 Mon Sep 17 00:00:00 2001 From: stre4m Date: Sun, 8 Sep 2024 19:44:06 +0500 Subject: [PATCH 2/2] =?UTF-8?q?hw-docker-compose:=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D1=8F=D0=B5=D1=82=20CI=20GitHub=20Actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..f0ac5a5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,34 @@ +name: Build ASP.NET Core 8 + +# Определяем, когда запускать этот workflow +on: + push: + branches: + - main # Запускаем при push в ветку main + pull_request: + branches: + - main # Запускаем при pull request в ветку main + +# Определяем среду выполнения +jobs: + build: + runs-on: ubuntu-latest # Используем последнюю версию Ubuntu + + steps: + # Проверяем код из репозитория + - name: Checkout repository + uses: actions/checkout@v3 + + # Устанавливаем .NET SDK (версию укажите ту, которая необходима для ASP.NET Core 8) + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '8.0.x' # Указываем нужную версию SDK + + # Восстанавливаем зависимости + - name: Restore dependencies + run: dotnet restore WebApi/WebApi.csproj + + # Сборка проекта + - name: Build project + run: dotnet build WebApi/WebApi.csproj --configuration Release --no-restore