Enable default GitHub auto-merge support (#5353)
- Add helper scripts to enable GitHub auto-merge - Enable Github auto-merge for version updates - Ignore errors from maven search for now because it is down
This commit is contained in:
Родитель
b8bdc81b4b
Коммит
cfa9386ce0
|
@ -65,7 +65,14 @@ steps:
|
|||
PushArgs: -f
|
||||
WorkingDirectory: $(AzureSDKClonePath)
|
||||
ScriptDirectory: $(AzureSDKToolsScriptsPath)
|
||||
PRLabels: 'auto-merge'
|
||||
|
||||
- pwsh: |
|
||||
. ./eng/scripts/Github-Helpers.ps1
|
||||
EnableAutoMergeForPullRequest -pullRequestNumber $(Submitted.PullRequest.Number)
|
||||
displayName: Apply AutoMerge to Pull Request
|
||||
workingDirectory: $(AzureSDKClonePath)
|
||||
env:
|
||||
GH_TOKEN: $(azuresdk-github-pat)
|
||||
|
||||
- template: template/steps/generate-releasenotes.yml
|
||||
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
# These features use a GitHub API that only works under specific conditions. All of the following conditions must be true for this action to succeed.
|
||||
|
||||
# The target repository must have Allow auto-merge enabled in settings.
|
||||
# The pull request base must have a branch protection rule with at least one requirement enabled.
|
||||
# The pull request must be in a state where requirements have not yet been satisfied. If the pull request can already be merged, attempting to enable auto-merge will fail.
|
||||
|
||||
function EnableAutoMergeForPullRequest([int]$pullRequestNumber, [string]$name="azure-sdk", [string]$owner="Azure")
|
||||
{
|
||||
# query MyQuery($number: Int = "", $owner: String = "", $name: String = "") {
|
||||
# repository(name: $name, owner: $owner) { pullRequest(number: $number) { id } }
|
||||
# }
|
||||
$projectQuery = 'query($name: String!, $owner: String!, $pullRequestNumber: Int!) { repository(name: $name, owner: $owner) { pullRequest(number: $pullRequestNumber) { id } } }'
|
||||
$selectQuery = ".data.repository.pullRequest.id"
|
||||
$pullRequestId = gh api graphql -f query=$projectQuery -F name=$name -F owner=$owner -F pullRequestNumber=$pullRequestNumber --jq $selectQuery
|
||||
if (!$LASTEXITCODE) {
|
||||
EnableAutoMergeForPullRequestId $pullRequestId
|
||||
}
|
||||
else {
|
||||
Write-Error "$pullRequestId`nLASTEXITCODE = $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
|
||||
function EnableAutoMergeForPullRequestId([string]$pullRequestId)
|
||||
{
|
||||
$response = gh api graphql -F pullRequestId=$pullRequestId -f query='
|
||||
mutation($pullRequestId: ID!) {
|
||||
enablePullRequestAutoMerge(input: {pullRequestId: $pullRequestId, mergeMethod: SQUASH}) {
|
||||
clientMutationId
|
||||
}
|
||||
}'
|
||||
|
||||
if ($LASTEXITCODE) {
|
||||
$responseJson = $response | ConvertFrom-Json
|
||||
if ($responseJson.errors.message -match "pull request is in (clean|unstable) status") {
|
||||
Write-Verbose "Unable to enable automerge. Make sure you have enabled branch protection with at least one status check marked as required."
|
||||
$LASTEXITCODE = 0
|
||||
}
|
||||
}
|
||||
if ($LASTEXITCODE) {
|
||||
Write-Error "$response`nLASTEXITCODE = $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
|
||||
function DisablePullRequestAutoMerge([string]$pullRequestId)
|
||||
{
|
||||
$response = gh api graphql -F pullRequestId=$pullRequestId -f query='
|
||||
mutation($pullRequestId: ID!) {
|
||||
disablePullRequestAutoMerge(input: {pullRequestId: $pullRequestId}) {
|
||||
clientMutationId
|
||||
}
|
||||
}'
|
||||
if ($LASTEXITCODE) {
|
||||
Write-Error "$response`nLASTEXITCODE = $LASTEXITCODE"
|
||||
}
|
||||
}
|
|
@ -332,13 +332,19 @@ function Write-Latest-Versions($lang)
|
|||
switch($language)
|
||||
{
|
||||
"all" {
|
||||
Write-Latest-Versions "java"
|
||||
Write-Latest-Versions "js"
|
||||
Write-Latest-Versions "dotnet"
|
||||
Write-Latest-Versions "python"
|
||||
Write-Latest-Versions "cpp"
|
||||
Write-Latest-Versions "go"
|
||||
Write-Latest-Versions "android"
|
||||
|
||||
# Currently ignoring errors for maven search site until incident is fixed
|
||||
# see https://github.com/Azure/azure-sdk/issues/5368
|
||||
try {
|
||||
Write-Latest-Versions "java"
|
||||
Write-Latest-Versions "android"
|
||||
}
|
||||
catch { }
|
||||
break
|
||||
}
|
||||
"java" {
|
||||
|
|
Загрузка…
Ссылка в новой задаче