Files
FA_WEB/.woodpecker.yml
2026-01-08 12:49:58 +00:00

134 lines
5.0 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: [push, tag, manual]
branch: [master]
steps:
clone-manual:
image: woodpeckerci/plugin-git
settings:
remote: http://172.0.0.1:3000/FA/FA_WEB.git
branch: master
depth: 1
restore:
image: mcr.microsoft.com/dotnet/sdk:latest
commands:
- |
set -euf
CODE_DIR="/woodpecker/src/srv51.mikr.us/git/FA/FA_WEB"
cd "$CODE_DIR"
echo "=== Restore wszystkich projektów ==="
find . -name "*.csproj" -type f -exec dotnet restore "{}" \;
test:
image: mcr.microsoft.com/dotnet/sdk:latest
commands:
- |
set -euf
CODE_DIR="/woodpecker/src/srv51.mikr.us/git/FA/FA_WEB"
cd "$CODE_DIR"
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
CODE_DIR="/woodpecker/src/srv51.mikr.us/git/FA/FA_WEB"
cd "$CODE_DIR"
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 "$CODE_DIR/nupkg"
else
PROJECT_NAME=$(basename "$csproj" .csproj)
echo "→ Pomijam $PROJECT_NAME brak <PackageId> (nie jest to biblioteka NuGet)"
fi
done
echo "=== Spakowane pakiety (.nupkg) ==="
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
CODE_DIR="/woodpecker/src/srv51.mikr.us/git/FA/FA_WEB"
cd "$CODE_DIR"
echo "=== Test połączenia z BaGetter ==="
curl -f http://baget:80/v3/index.json || echo "Nie można połączyć się z BaGetter!"
# Tworzymy minimalny NuGet.Config tylko po to, żeby odblokować HTTP dla nazwanego źródła
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 "=== Użyty NuGet.Config (tylko do odblokowania HTTP) ==="
cat NuGet.Config
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
echo "Wszystkie pakiety DataModel opublikowane w BaGetter!"
depends_on: [pack-datamodels]
build-and-publish-apps:
image: mcr.microsoft.com/dotnet/sdk:latest
# environment:
# DEPLOY_SSH_KEY:
# from_secret: deploy_ssh_key
commands:
- |
set -euf
CODE_DIR="/woodpecker/src/srv51.mikr.us/git/FA/FA_WEB"
cd "$CODE_DIR"
echo "=== Ponowny restore aplikacji (z najnowszymi pakietami z BaGetter) ==="
find . -name "*.csproj" -type f -exec dotnet restore "{}" \;
echo "=== Publish aplikacji ==="
find . -name "*.csproj" -type f | while read csproj; do
PROJECT_NAME=$(basename "$csproj" .csproj)
PROJECT_DIR=$(dirname "$csproj")
if [[ "$PROJECT_NAME" == *"Api"* ]] || [[ "$PROJECT_NAME" == *"Blazor"* ]] || [[ "$PROJECT_DIR" == *"/Api/"* ]] || [[ "$PROJECT_DIR" == *"/Blazor/"* ]]; then
DEPLOY_TO_CENTRAL=$(dotnet msbuild "$csproj" -getProperty:DeployToCentral -noLogo 2>/dev/null || echo "false")
if [ "$DEPLOY_TO_CENTRAL" != "true" ]; then
echo "Pomijam $PROJECT_NAME (DeployToCentral ≠ true)"
continue
fi
echo "→ Publish $PROJECT_NAME ($csproj)"
dotnet publish "$csproj" --no-restore -c Release -o "$CODE_DIR/publish-$PROJECT_NAME"
# ←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←
# Tu wstaw swój kod deployu (rsync/ssh itp.)
# ←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←←
else
echo "Pomijam $PROJECT_NAME (nie jest to Api ani Blazor)"
fi
done
echo "Pipeline zakończony pomyślnie!"
depends_on: [publish-datamodels-to-baget]