diff --git a/.github/actions/validate-deploy/action.yml b/.github/actions/validate-deploy/action.yml index 5c5bdf07..d5c092cd 100644 --- a/.github/actions/validate-deploy/action.yml +++ b/.github/actions/validate-deploy/action.yml @@ -17,20 +17,26 @@ runs: # - name: "Diff" - shell: bash + shell: pwsh run: | - if [ ! -z "$(git diff --name-status HEAD^ HEAD)" ]; then - echo $(git diff --name-status HEAD^ HEAD) - git diff --name-status HEAD^ HEAD > /tmp/diff.txt - if [ ! -z "$(git diff --diff-filter=D HEAD^ HEAD --no-renames)" ]; then - echo $(git diff --diff-filter=D HEAD^ HEAD --no-prefix --no-renames | grep ^- | sed -r "s/^([^-+ ]*)[-+ ]/\\1/" | less -r) - git diff --diff-filter=D HEAD^ HEAD --no-prefix --no-renames | grep ^- | sed -r "s/^([^-+ ]*)[-+ ]/\\1/" | less -r > /tmp/diffdeletedfiles.txt - fi - else - echo "The validation pipeline failed because there is currently no change to be processed" + $gitDiff = git diff --name-status HEAD^ HEAD + if ($null -ne $gitDiff) { + $gitDiff | Write-Host + $gitDiff | Out-File -FilePath '/tmp/diff.txt' + + $deletedContent = git diff --diff-filter=D HEAD^ HEAD --no-prefix --no-renames + if($null -ne $deletedContent) { + $deletedContent = $deletedContent -match '^-' -replace '^([^-+ ]*)[-+ ]', '$1' + Write-Host '##[group]Deleted files content' + $deletedContent | Write-Host + Write-Host '##[endgroup]' + $deletedContent | Out-File -FilePath '/tmp/diffdeletedfiles.txt' + } + } + else { + Write-Host '##[error]The validation pipeline failed because there is currently no change to be processed' exit 1 - fi - + } # # Deploy # Initial deployment of any index changes diff --git a/.pipelines/.templates/validate-deploy.yml b/.pipelines/.templates/validate-deploy.yml index 24a25e6a..c38e8598 100644 --- a/.pipelines/.templates/validate-deploy.yml +++ b/.pipelines/.templates/validate-deploy.yml @@ -10,22 +10,29 @@ steps: # List index changes # - - task: Bash@3 + - task: PowerShell@2 displayName: "Diff" inputs: targetType: "inline" script: | - if [ ! -z "$(git diff --name-status HEAD^ HEAD)" ]; then - echo $(git diff --name-status HEAD^ HEAD) - git diff --name-status HEAD^ HEAD > /tmp/diff.txt - if [ ! -z "$(git diff --diff-filter=D HEAD^ HEAD --no-renames)" ]; then - echo $(git diff --diff-filter=D HEAD^ HEAD --no-prefix --no-renames | grep ^- | sed -r "s/^([^-+ ]*)[-+ ]/\\1/" | less -r) - git diff --diff-filter=D HEAD^ HEAD --no-prefix --no-renames | grep ^- | sed -r "s/^([^-+ ]*)[-+ ]/\\1/" | less -r > /tmp/diffdeletedfiles.txt - fi - else - echo "The validation pipeline failed because there is currently no change to be processed" - exit 1 - fi + $gitDiff = git diff --name-status HEAD^ HEAD + if($null -ne $gitDiff) { + $gitDiff | Write-Host + $gitDiff | Out-File -FilePath '/tmp/diff.txt' + + $deletedContent = git diff --diff-filter=D HEAD^ HEAD --no-prefix --no-renames + if($null -ne $deletedContent) { + $deletedContent = $deletedContent -match '^-' -replace '^([^-+ ]*)[-+ ]', '$1' + Write-Host '##[group]Deleted files content' + $deletedContent | Write-Host + Write-Host '##[endgroup]' + $deletedContent | Out-File -FilePath '/tmp/diffdeletedfiles.txt' + } + } + else { + Write-Host '##[error]The validation pipeline failed because there is currently no change to be processed' + exit 1 + } # # Validate or Deploy