mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 20:57:22 +02:00
[CI]Fix prebuild check to use commit when no pull request number exists (#29846)
This commit is contained in:
@@ -15,13 +15,24 @@ jobs:
|
|||||||
inputs:
|
inputs:
|
||||||
targetType: 'inline'
|
targetType: 'inline'
|
||||||
script: |
|
script: |
|
||||||
$pullRequestNumber = "$(system.pullRequest.pullRequestNumber)";
|
try {
|
||||||
$gitHubPullRequest = Invoke-RestMethod -Method Get "https://api.github.com/repos/microsoft/PowerToys/pulls/$pullRequestNumber/files"
|
# Try based on pull request first
|
||||||
# If there are no files updated in the commit that are .md, set skipBuild variable
|
$pullRequestNumber = "$(system.pullRequest.pullRequestNumber)";
|
||||||
if(([array]($gitHubPullRequest.filename) -notmatch ".md|.txt").Length -eq 0)
|
$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 '##vso[task.setvariable variable=skipBuild;isOutput=true]Yes'
|
||||||
Write-Host 'Skipping Build'
|
Write-Host 'Skipping Build'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
pwsh: true
|
pwsh: true
|
||||||
name: verifyBuildRequest
|
name: verifyBuildRequest
|
||||||
|
|||||||
Reference in New Issue
Block a user