* Added step to detect projects which have been changed
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
This commit is contained in:
@@ -5,6 +5,41 @@ when:
|
||||
- merge
|
||||
branch: master
|
||||
steps:
|
||||
detect-changed-projects:
|
||||
image: alpine
|
||||
commands:
|
||||
- |
|
||||
set -euf
|
||||
cd "${CI_WORKSPACE}"
|
||||
|
||||
echo "CI_PIPELINE_FILES=${CI_PIPELINE_FILES}"
|
||||
|
||||
# Zapisz listę zmienionych plików do JSON
|
||||
echo "${CI_PIPELINE_FILES:-[]}" > changed-files.json
|
||||
|
||||
# Wyciągnij katalogi z plików i zmapuj na csproj
|
||||
apk add --no-cache jq findutils
|
||||
|
||||
> changed-projects.txt
|
||||
|
||||
jq -r '.[]' changed-files.json | while read path; do
|
||||
# znajdź najbliższy .csproj w górę od zmienionego pliku
|
||||
dir=$(dirname "$path")
|
||||
while [ "$dir" != "." ] && [ "$dir" != "/" ]; do
|
||||
csproj=$(find "$dir" -maxdepth 1 -name "*.csproj" -type f | head -n 1 || true)
|
||||
if [ -n "$csproj" ]; then
|
||||
echo "$csproj" >> changed-projects.txt
|
||||
break
|
||||
fi
|
||||
dir=$(dirname "$dir")
|
||||
done
|
||||
done
|
||||
|
||||
# unikalne projekty
|
||||
sort -u -o changed-projects.txt changed-projects.txt
|
||||
|
||||
echo "Zmienione projekty:"
|
||||
cat changed-projects.txt || echo "brak"
|
||||
debug-location:
|
||||
image: alpine
|
||||
commands:
|
||||
@@ -25,7 +60,20 @@ steps:
|
||||
cd "${CI_WORKSPACE}"
|
||||
echo "Aktualna ścieżka do pliku: $(pwd)"
|
||||
echo "=== Restore wszystkich projektów ==="
|
||||
find . -name "*.csproj" -type f -exec dotnet restore "{}" \;
|
||||
|
||||
if [ ! -s changed-projects.txt ]; then
|
||||
echo "Brak zmienionych projektów – nic do restore."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "=== Restore zmienionych projektów ==="
|
||||
while read csproj; do
|
||||
echo "→ dotnet restore $csproj"
|
||||
dotnet restore "$csproj"
|
||||
done < changed-projects.txt
|
||||
|
||||
# find . -name "*.csproj" -type f -exec dotnet restore "{}" \;
|
||||
depends_on: [detect-changed-projects]
|
||||
test:
|
||||
image: mcr.microsoft.com/dotnet/sdk:latest
|
||||
commands:
|
||||
|
||||
Reference in New Issue
Block a user