This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
skip_clone: true
|
skip_clone: true
|
||||||
|
|
||||||
when:
|
when:
|
||||||
event: pull_request
|
event: pull_request
|
||||||
action:
|
action:
|
||||||
- merge
|
- merge
|
||||||
branch: master
|
branch: master
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
debug-location:
|
debug-location:
|
||||||
image: alpine
|
image: alpine
|
||||||
@@ -11,12 +13,14 @@ steps:
|
|||||||
- pwd
|
- pwd
|
||||||
- ls -la
|
- ls -la
|
||||||
- find /woodpecker -maxdepth 4 -type d 2>/dev/null
|
- find /woodpecker -maxdepth 4 -type d 2>/dev/null
|
||||||
|
|
||||||
clone-manual:
|
clone-manual:
|
||||||
image: woodpeckerci/plugin-git
|
image: woodpeckerci/plugin-git
|
||||||
settings:
|
settings:
|
||||||
remote: http://gitea:3000/FA/FA_WEB.git
|
remote: http://gitea:3000/FA/FA_WEB.git
|
||||||
branch: master
|
branch: master
|
||||||
depth: 1
|
depth: 1
|
||||||
|
|
||||||
restore:
|
restore:
|
||||||
image: mcr.microsoft.com/dotnet/sdk:latest
|
image: mcr.microsoft.com/dotnet/sdk:latest
|
||||||
commands:
|
commands:
|
||||||
@@ -26,6 +30,7 @@ steps:
|
|||||||
echo "Aktualna ścieżka: $(pwd)"
|
echo "Aktualna ścieżka: $(pwd)"
|
||||||
echo "=== Restore wszystkich projektów ==="
|
echo "=== Restore wszystkich projektów ==="
|
||||||
find . -name "*.csproj" -type f -exec dotnet restore "{}" \;
|
find . -name "*.csproj" -type f -exec dotnet restore "{}" \;
|
||||||
|
|
||||||
test:
|
test:
|
||||||
image: mcr.microsoft.com/dotnet/sdk:latest
|
image: mcr.microsoft.com/dotnet/sdk:latest
|
||||||
commands:
|
commands:
|
||||||
@@ -35,6 +40,7 @@ steps:
|
|||||||
echo "=== Uruchamianie testów ==="
|
echo "=== Uruchamianie testów ==="
|
||||||
dotnet test --no-restore --configuration Release --logger "trx"
|
dotnet test --no-restore --configuration Release --logger "trx"
|
||||||
depends_on: [restore]
|
depends_on: [restore]
|
||||||
|
|
||||||
pack-datamodels:
|
pack-datamodels:
|
||||||
image: mcr.microsoft.com/dotnet/sdk:latest
|
image: mcr.microsoft.com/dotnet/sdk:latest
|
||||||
commands:
|
commands:
|
||||||
@@ -78,6 +84,7 @@ steps:
|
|||||||
echo "=== Spakowane pakiety ==="
|
echo "=== Spakowane pakiety ==="
|
||||||
ls -la nupkg/ || echo "Brak spakowanych pakietów!"
|
ls -la nupkg/ || echo "Brak spakowanych pakietów!"
|
||||||
depends_on: [test]
|
depends_on: [test]
|
||||||
|
|
||||||
publish-datamodels-to-baget:
|
publish-datamodels-to-baget:
|
||||||
image: mcr.microsoft.com/dotnet/sdk:latest
|
image: mcr.microsoft.com/dotnet/sdk:latest
|
||||||
environment:
|
environment:
|
||||||
@@ -108,6 +115,7 @@ steps:
|
|||||||
--skip-duplicate
|
--skip-duplicate
|
||||||
done
|
done
|
||||||
depends_on: [pack-datamodels]
|
depends_on: [pack-datamodels]
|
||||||
|
|
||||||
prepare-for-container:
|
prepare-for-container:
|
||||||
image: mcr.microsoft.com/dotnet/sdk:latest
|
image: mcr.microsoft.com/dotnet/sdk:latest
|
||||||
commands:
|
commands:
|
||||||
@@ -117,6 +125,7 @@ steps:
|
|||||||
dotnet restore
|
dotnet restore
|
||||||
echo "Przygotowanie do konteneryzacji wykonane (restore zrobione)"
|
echo "Przygotowanie do konteneryzacji wykonane (restore zrobione)"
|
||||||
depends_on: [publish-datamodels-to-baget]
|
depends_on: [publish-datamodels-to-baget]
|
||||||
|
|
||||||
containerize-apps:
|
containerize-apps:
|
||||||
image: woodpeckerci/plugin-docker-buildx:latest
|
image: woodpeckerci/plugin-docker-buildx:latest
|
||||||
environment:
|
environment:
|
||||||
@@ -128,45 +137,59 @@ steps:
|
|||||||
- |
|
- |
|
||||||
set -euf
|
set -euf
|
||||||
cd "${CI_WORKSPACE}"
|
cd "${CI_WORKSPACE}"
|
||||||
|
|
||||||
echo "DEBUG: Użytkownik = '$GITEA_USER'"
|
echo "DEBUG: Użytkownik = '$GITEA_USER'"
|
||||||
echo "DEBUG: Token (pierwsze 4 znaki) = $GITEA_TOKEN..."
|
echo "DEBUG: Token (pierwsze 4 znaki) = ${GITEA_TOKEN:0:4}..."
|
||||||
|
|
||||||
echo "$GITEA_TOKEN" | docker login git.modwad.pl -u "$GITEA_USER" --password-stdin
|
echo "$GITEA_TOKEN" | docker login git.modwad.pl -u "$GITEA_USER" --password-stdin
|
||||||
|
|
||||||
find . -name "*.csproj" -type f | while read csproj; do
|
find . -name "*.csproj" -type f | while read csproj; do
|
||||||
PROJECT_DIR=$(dirname "$csproj")
|
PROJECT_DIR=$(dirname "$csproj")
|
||||||
PROJECT_NAME=$(basename "$csproj" .csproj)
|
PROJECT_NAME=$(basename "$csproj" .csproj)
|
||||||
PROJECT_TYPE=$(dotnet msbuild "$csproj" -getProperty:ProjectType -noLogo 2>/dev/null || echo "Unknown")
|
|
||||||
DEPLOY_TO_CENTRAL=$(dotnet msbuild "$csproj" -getProperty:DeployToCentral -noLogo 2>/dev/null || echo "false")
|
# bezpieczniejsze pobieranie właściwości (bez errorów w logach)
|
||||||
if [ "$DEPLOY_TO_CENTRAL" != "true" ] || [[ "$PROJECT_TYPE" == "Unknown" || "$PROJECT_TYPE" == "DataModel" || "$PROJECT_TYPE" == "LinuxLocal" ]]; then
|
PROJECT_TYPE=$(dotnet msbuild "$csproj" -getProperty:ProjectType -nologo 2>/dev/null || echo "Unknown")
|
||||||
|
DEPLOY_TO_CENTRAL=$(dotnet msbuild "$csproj" -getProperty:DeployToCentral -nologo 2>/dev/null || echo "false")
|
||||||
|
|
||||||
|
if [ "$DEPLOY_TO_CENTRAL" != "true" ] || [ "$PROJECT_TYPE" = "Unknown" ] || [ "$PROJECT_TYPE" = "DataModel" ] || [ "$PROJECT_TYPE" = "LinuxLocal" ]; then
|
||||||
echo "Pomijam $PROJECT_NAME ($PROJECT_TYPE)"
|
echo "Pomijam $PROJECT_NAME ($PROJECT_TYPE)"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IMAGE_NAME="trent/${PROJECT_NAME,,}"
|
IMAGE_NAME="trent/${PROJECT_NAME,,}"
|
||||||
FULL_IMAGE="git.modwad.pl/${IMAGE_NAME}"
|
FULL_IMAGE="git.modwad.pl/${IMAGE_NAME}"
|
||||||
cat > "${PROJECT_DIR}/Dockerfile.temp" <<-EOF
|
|
||||||
|
cat > "${PROJECT_DIR}/Dockerfile.temp" <<-'EOF'
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN dotnet restore "${PROJECT_NAME}.csproj"
|
RUN dotnet restore "${PROJECT_NAME}.csproj"
|
||||||
RUN dotnet publish "${PROJECT_NAME}.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
RUN dotnet publish "${PROJECT_NAME}.csproj" -c Release -o /app/publish /p:UseAppHost=false
|
||||||
|
|
||||||
FROM base AS final
|
FROM base AS final
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /app/publish .
|
COPY --from=build /app/publish .
|
||||||
ENV ASPNETCORE_URLS=http://+:8080
|
ENV ASPNETCORE_URLS=http://+:8080
|
||||||
ENTRYPOINT ["dotnet", "${PROJECT_NAME}.dll"]
|
ENTRYPOINT ["dotnet", "${PROJECT_NAME}.dll"]
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Buduję → ${FULL_IMAGE}:${CI_COMMIT_SHA}"
|
echo "Buduję → ${FULL_IMAGE}:${CI_COMMIT_SHA}"
|
||||||
|
|
||||||
docker buildx build --platform linux/amd64 \
|
docker buildx build --platform linux/amd64 \
|
||||||
-t "${FULL_IMAGE}:${CI_COMMIT_SHA}" \
|
-t "${FULL_IMAGE}:${CI_COMMIT_SHA}" \
|
||||||
-t "${FULL_IMAGE}:latest" \
|
-t "${FULL_IMAGE}:latest" \
|
||||||
-f "${PROJECT_DIR}/Dockerfile.temp" \
|
-f "${PROJECT_DIR}/Dockerfile.temp" \
|
||||||
"${PROJECT_DIR}"
|
"${PROJECT_DIR}"
|
||||||
|
|
||||||
docker push "${FULL_IMAGE}:${CI_COMMIT_SHA}"
|
docker push "${FULL_IMAGE}:${CI_COMMIT_SHA}"
|
||||||
docker push "${FULL_IMAGE}:latest"
|
docker push "${FULL_IMAGE}:latest"
|
||||||
|
|
||||||
rm -f "${PROJECT_DIR}/Dockerfile.temp"
|
rm -f "${PROJECT_DIR}/Dockerfile.temp"
|
||||||
|
|
||||||
echo "Opublikowano: ${FULL_IMAGE}:latest"
|
echo "Opublikowano: ${FULL_IMAGE}:latest"
|
||||||
done
|
done
|
||||||
depends_on: [prepare-for-container]
|
depends_on: [prepare-for-container]
|
||||||
Reference in New Issue
Block a user