pipeline und controller
This commit is contained in:
42
.gitea/workflows/pipeline.yml
Normal file
42
.gitea/workflows/pipeline.yml
Normal file
@@ -0,0 +1,42 @@
|
||||
# Name Ihrer Workflow-Pipeline
|
||||
name: Build and Push Backend API Docker Image
|
||||
|
||||
# Definiert, wann dieser Workflow ausgeführt werden soll
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master # Wird ausgelöst bei jedem Push auf den Master-Branch
|
||||
|
||||
# Definition der Jobs, die in diesem Workflow ausgeführt werden
|
||||
jobs:
|
||||
build-and-push:
|
||||
# Der Runner, auf dem der Job ausgeführt wird (eine virtuelle Maschine)
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Schritte, die auf dem Runner ausgeführt werden
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
# Checkt Ihren Code aus dem Repository in den Runner
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Login to Gitea Container Registry
|
||||
# Meldet sich bei Ihrer Gitea Container Registry an
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: gitea.tzbre.dev
|
||||
username: ${{ github.actor }} # Verwendet den GitHub-Benutzer, der den Push ausgelöst hat
|
||||
password: ${{ secrets.TOKEN }} # Verwendet ein GitHub Secret für das Passwort/Personal Access Token
|
||||
|
||||
- name: Build and push Backend API Docker image
|
||||
# Baut das Docker-Image für Ihre API und pusht es in die Registry
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
# Der Kontext für den Docker-Build ist das Wurzelverzeichnis des Repositories.
|
||||
# Das ist wichtig, da das Dockerfile auf Dateien in verschiedenen Unterordnern zugreift (z.B. Webshop.Api.csproj, ShopSolution.sln).
|
||||
context: .
|
||||
# Der spezifische Pfad zu Ihrem Dockerfile innerhalb des Kontexts.
|
||||
file: Webshop.Api/Dockerfile
|
||||
# Legt fest, dass das Image nach dem Bauen in die Registry gepusht werden soll
|
||||
push: true
|
||||
# Definiert die Tags für Ihr Docker-Image in der Registry
|
||||
tags: gitea.tzbre.dev/admin/shopsolution-backend:latest # WICHTIG: Eindeutiger Name für das Backend-Image
|
||||
@@ -22,5 +22,13 @@ namespace Webshop.Api.Controllers
|
||||
var products = await _productService.GetAllProductsAsync();
|
||||
return Ok(products);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<ProductDto>> CreateProduct([FromBody] ProductDto productDto)
|
||||
{
|
||||
var createdProduct = await _productService.CreateProductAsync(productDto);
|
||||
|
||||
return CreatedAtAction(nameof(GetAllProducts), new { id = createdProduct.Id }, createdProduct);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Webshop.Application
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -28,5 +28,21 @@ namespace Webshop.Application.Services
|
||||
|
||||
return productDtos;
|
||||
}
|
||||
|
||||
public async Task<ProductDto> CreateProductAsync(ProductDto productDto)
|
||||
{
|
||||
var newProduct = new Domain.Entities.Product
|
||||
{
|
||||
Name = productDto.Name,
|
||||
Description = productDto.Description,
|
||||
Price = productDto.Price,
|
||||
SKU = productDto.Sku
|
||||
};
|
||||
|
||||
await _productRepository.AddProductAsync(newProduct);
|
||||
|
||||
productDto.Id = newProduct.Id;
|
||||
return productDto;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user