Files
FA_WEB/.woodpecker.yml
trent a0451c42de
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
Update .woodpecker.yml
2026-01-15 09:53:19 +00:00

181 lines
6.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
skip_clone: true
when:
event: pull_request
action:
- merge
branch: master
steps:
debug-location:
image: alpine
commands:
- pwd
- ls -la
- find /woodpecker -maxdepth 4 -type d 2>/dev/null
clone-manual:
image: woodpeckerci/plugin-git
settings:
remote: http://gitea:3000/FA/FA_WEB.git
branch: master
depth: 1
restore:
image: mcr.microsoft.com/dotnet/sdk:latest
commands:
- |
set -euf
cd "${CI_WORKSPACE}"
echo "Aktualna ścieżka: $(pwd)"
echo "=== Restore wszystkich projektów ==="
find . -name "*.csproj" -type f -exec dotnet restore "{}" \;
test:
image: mcr.microsoft.com/dotnet/sdk:latest
commands:
- |
set -euf
cd "${CI_WORKSPACE}"
echo "=== Uruchamianie testów ==="
dotnet test --no-restore --configuration Release --logger "trx"
depends_on: [restore]
pack-datamodels:
image: mcr.microsoft.com/dotnet/sdk:latest
commands:
- |
set -euf
cd "${CI_WORKSPACE}"
echo "=== Instalacja MinVer CLI ==="
dotnet tool install --tool-path /tmp/minver minver-cli
echo "=== Obliczona wersja przez MinVer ==="
MINVER_VERSION=$(/tmp/minver/minver \
--auto-increment patch \
--minimum-major-minor 2.0 \
--default-pre-release-identifiers alpha.0 \
--verbosity info)
echo "Wersja: $MINVER_VERSION"
mkdir -p nupkg
echo "=== Pełniejsze fetch git (unshallow + tags) ==="
git fetch --prune --unshallow || echo "Już full clone OK"
git fetch --tags
echo "=== Dostępne tagi ==="
git tag -l
echo "=== Aktualny commit i opis ==="
git describe --tags --always --dirty
echo "=== Diagnostyka projektów ==="
find . -name "*.csproj" -type f | sort
mkdir -p nupkg
echo "=== Pakowanie projektów DataModel (wykrywane po obecności <PackageId>) ==="
find . -name "*.csproj" -type f | while read csproj; do
if grep -q '<PackageId>' "$csproj"; then
PROJECT_NAME=$(basename "$csproj" .csproj)
echo "→ Pakuję $PROJECT_NAME ($csproj)"
dotnet pack "$csproj" \
--configuration Release \
-o "./nupkg" \
/p:PackageVersion=$MINVER_VERSION
else
PROJECT_NAME=$(basename "$csproj" .csproj)
echo "→ Pomijam $PROJECT_NAME brak <PackageId>"
fi
done
echo "=== Spakowane pakiety ==="
ls -la nupkg/ || echo "Brak spakowanych pakietów!"
depends_on: [test]
publish-datamodels-to-baget:
image: mcr.microsoft.com/dotnet/sdk:latest
environment:
BAGETTER_API_KEY:
from_secret: baget_api_key
commands:
- |
set -euf
cd "${CI_WORKSPACE}"
echo "=== Test połączenia z BaGetter ==="
curl -f http://baget:80/v3/index.json || echo "Nie można połączyć się z BaGetter!"
cat <<EOF > NuGet.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="BaGet" value="http://baget:80/v3/index.json" allowInsecureConnections="true" />
</packageSources>
</configuration>
EOF
echo "=== Publikacja pakietów do BaGetter ==="
find ./nupkg -name "*.nupkg" -type f | while read pkg; do
echo "→ Push $(basename "$pkg")"
dotnet nuget push "$pkg" \
--source "BaGet" \
--api-key "$BAGETTER_API_KEY" \
--skip-duplicate
done
depends_on: [pack-datamodels]
select-projects-for-container:
image: mcr.microsoft.com/dotnet/sdk:latest
commands:
- |
set -euf
cd "${CI_WORKSPACE}"
> projects-to-build.txt
find . -name "*.csproj" -type f | while read csproj; do
PROJECT_TYPE=$(dotnet msbuild "$csproj" -getProperty:ProjectType -noLogo 2>/dev/null || echo "Unknown")
if [[ "$PROJECT_TYPE" == "Unknown" || "$PROJECT_TYPE" == "DataModel" || "$PROJECT_TYPE" == "LinuxLocal" ]]; then
:
else
PROJECT_NAME=$(basename "$csproj" .csproj)
PROJECT_DIR=$(dirname "$csproj")
echo "$PROJECT_DIR|$PROJECT_NAME" >> projects-to-build.txt
fi
done
depends_on: [publish-datamodels-to-baget]
containerize-apps:
image: woodpeckerci/plugin-docker-buildx:latest
environment:
DOCKER_HOST: unix:///var/run/docker.sock
GITEA_USER:
from_secret: gitea_registry_user
GITEA_TOKEN:
from_secret: gitea_registry_token
commands:
- |
set -euf
cd "${CI_WORKSPACE}"
echo "DEBUG: DOCKER_HOST = $DOCKER_HOST"
echo "DEBUG: ls /var/run/docker.sock:"
ls -l /var/run/docker.sock || echo "Socket NIE widoczny"
echo "DEBUG: Użytkownik = '$GITEA_USER'"
echo "DEBUG: Token (pierwsze 4 znaki) = $GITEA_TOKEN..."
echo "$GITEA_TOKEN" | docker login git.modwad.pl -u "$GITEA_USER" --password-stdin
if [ ! -s projects-to-build.txt ]; then
echo "Brak projektów do zbudowania"
exit 0
fi
while IFS='|' read -r PROJECT_DIR PROJECT_NAME; do
if [ -z "$PROJECT_NAME" ]; then continue; fi
IMAGE_NAME="trent/${PROJECT_NAME,,}"
FULL_IMAGE="git.modwad.pl/${IMAGE_NAME}"
cat > "${PROJECT_DIR}/Dockerfile.temp" <<-EOF
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 8080
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
RUN dotnet restore "${PROJECT_NAME}.csproj"
RUN dotnet publish "${PROJECT_NAME}.csproj" -c Release -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=build /app/publish .
ENV ASPNETCORE_URLS=http://+:8080
ENTRYPOINT ["dotnet", "${PROJECT_NAME}.dll"]
EOF
echo "Buduję → ${FULL_IMAGE}:${CI_COMMIT_SHA}"
docker buildx build --platform linux/amd64 \
-t "${FULL_IMAGE}:${CI_COMMIT_SHA}" \
-t "${FULL_IMAGE}:latest" \
-f "${PROJECT_DIR}/Dockerfile.temp" \
"${PROJECT_DIR}"
docker push "${FULL_IMAGE}:${CI_COMMIT_SHA}"
docker push "${FULL_IMAGE}:latest"
rm -f "${PROJECT_DIR}/Dockerfile.temp"
echo "Opublikowano: ${FULL_IMAGE}:latest"
done < projects-to-build.txt
depends_on: [select-projects-for-container]