[CI]Fix prebuild check to use commit when no pull request number exists (#29846)

This commit is contained in:
Jeremy Sinclair 2023-11-14 12:04:26 -05:00 коммит произвёл GitHub
Родитель 0990724e44
Коммит 887d475560
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 17 добавлений и 6 удалений

Просмотреть файл

@ -15,13 +15,24 @@ jobs:
inputs:
targetType: 'inline'
script: |
$pullRequestNumber = "$(system.pullRequest.pullRequestNumber)";
$gitHubPullRequest = Invoke-RestMethod -Method Get "https://api.github.com/repos/microsoft/PowerToys/pulls/$pullRequestNumber/files"
# If there are no files updated in the commit that are .md, set skipBuild variable
if(([array]($gitHubPullRequest.filename) -notmatch ".md|.txt").Length -eq 0)
{
try {
# Try based on pull request first
$pullRequestNumber = "$(system.pullRequest.pullRequestNumber)";
$gitHubPullRequest = Invoke-RestMethod -Method Get "https://api.github.com/repos/microsoft/PowerToys/pulls/$pullRequestNumber/files"
# If there are no files updated in the commit that are .md, set skipBuild variable
if(([array]($gitHubPullRequest.filename) -notmatch ".md|.txt").Length -eq 0) {
Write-Host '##vso[task.setvariable variable=skipBuild;isOutput=true]Yes'
Write-Host 'Skipping Build'
}
}
catch {
# Fall back to the latest commit otherwise.
$commit = "$(system.pullRequest.sourceCommitId)";
$gitHubCommit = Invoke-RestMethod -Method Get "https://api.github.com/repos/microsoft/PowerToys/commits/$commit"
if(([array]($githubCommit.files.filename) -notmatch ".md|.txt").Length -eq 0) {
Write-Host '##vso[task.setvariable variable=skipBuild;isOutput=true]Yes'
Write-Host 'Skipping Build'
}
}
pwsh: true
name: verifyBuildRequest
name: verifyBuildRequest