Skip to content

Commit

Permalink
Add a script to create PR from azure pipeline (Azure#19718)
Browse files Browse the repository at this point in the history
* Add script to create pr

* update

* update

* update

Co-authored-by: wyunchi-ms <yunwang@microsoft.com>
  • Loading branch information
azure-powershell-bot and wyunchi-ms authored Sep 30, 2022
1 parent 536930c commit 2a57296
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 61 deletions.
3 changes: 2 additions & 1 deletion .azure-pipelines/SyncFromMainBranchConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"build.proj",
"src/Az.Test.props",
"src/Az.autorest.hybrid.props",
"src/psm1.props"
"src/psm1.props",
"NuGet.Config"
],
"UnSyncPath": [
".azure-pipelines/SyncFromMainBranchConfig.json"
Expand Down
35 changes: 5 additions & 30 deletions .azure-pipelines/code-gen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,34 +97,9 @@ jobs:
git push origin codegen/${{ parameters.ServiceName }} --force;
displayName: Create codegen/${{ parameters.ServiceName }} branch
- pwsh: |
$Headers = @{"Accept" = "application/vnd.github+json"; "Authorization" = "Bearer $(BotAccessToken)"}
$PrBody = @'
<!-- DO NOT DELETE THIS TEMPLATE -->
## Description
<!-- Please add a brief description of the changes made in this PR. If you have an ongoing or finished cmdlet design, please paste the link below. -->
## Checklist
- [x] Check this box to confirm: **I have read the [_Submitting Changes_](../blob/main/CONTRIBUTING.md#submitting-changes) section of [`CONTRIBUTING.md`](../blob/main/CONTRIBUTING.md) and reviewed the following information:**
* **SHOULD** select appropriate branch. Cmdlets from Autorest.PowerShell should go to [`generation`](https://github.com/Azure/azure-powershell/tree/generation) branch.
* **SHOULD** make the title of PR clear and informative, and in the present imperative tense.
* **SHOULD** update `ChangeLog.md` file(s) appropriately
* For any service, the `ChangeLog.md` file can be found at `src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md`
* A snippet outlining the change(s) made in the PR should be written under the `## Upcoming Release` header in the past tense. Add changelog in description section if PR goes into [`generation`](https://github.com/Azure/azure-powershell/tree/generation) branch.
* Should **not** change `ChangeLog.md` if no new release is required, such as fixing test case only.
* **SHOULD** have approved design review for the changes in [this repository](https://github.com/Azure/azure-powershell-cmdlet-review-pr) ([_Microsoft internal only_](../blob/main/CONTRIBUTING.md#onboarding)) with following situations
* Create new module from scratch
* Create new resource types which are not easy to conform to [Azure PowerShell Design Guidelines](../blob/main/documentation/development-docs/design-guidelines)
* Create new resource type which name doesn't use module name as prefix
* Have design question before implementation
* **SHOULD** regenerate markdown help files if there is cmdlet API change. [Instruction](../blob/main/documentation/development-docs/help-generation.md#updating-all-markdown-files-in-a-module)
* **SHOULD** have proper test coverage for changes in pull request.
* **SHOULD NOT** introduce [breaking changes](../blob/main/documentation/breaking-changes/breaking-changes-definition.md) in Az minor release except preview version.
* **SHOULD NOT** adjust version of module manually in pull request
'@
$RequestBody = @{"title" = "Migrate ${{ parameters.ServiceName }} from generation to ${{ parameters.TargetBranch }}"; "body" = $PrBody; "head" = "codegen/${{ parameters.ServiceName }}"; "base" = "${{ parameters.TargetBranch }}" }
Invoke-WebRequest -Uri https://api.github.com/repos/Azure/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json)
$Title = "Migrate ${{ parameters.ServiceName }} from generation to ${{ parameters.TargetBranch }}"
$HeadBranch = "codegen/${{ parameters.ServiceName }}"
$BaseBranch = "${{ parameters.TargetBranch }}"
$Description = "Migrate ${{ parameters.ServiceName }} from generation to ${{ parameters.TargetBranch }}"
./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(BotAccessToken) -Description $Description
displayName: Create PR to main branch
35 changes: 5 additions & 30 deletions .azure-pipelines/sync-tools-folder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,9 @@ jobs:
pwsh: true

- pwsh: |
$Headers = @{"Accept" = "application/vnd.github+json"; "Authorization" = "Bearer $(GithubToken)"}
$PrBody = @'
<!-- DO NOT DELETE THIS TEMPLATE -->
## Description
<!-- Please add a brief description of the changes made in this PR. If you have an ongoing or finished cmdlet design, please paste the link below. -->
## Checklist
- [x] Check this box to confirm: **I have read the [_Submitting Changes_](../blob/main/CONTRIBUTING.md#submitting-changes) section of [`CONTRIBUTING.md`](../blob/main/CONTRIBUTING.md) and reviewed the following information:**
* **SHOULD** select appropriate branch. Cmdlets from Autorest.PowerShell should go to [`generation`](https://github.com/Azure/azure-powershell/tree/generation) branch.
* **SHOULD** make the title of PR clear and informative, and in the present imperative tense.
* **SHOULD** update `ChangeLog.md` file(s) appropriately
* For any service, the `ChangeLog.md` file can be found at `src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md`
* A snippet outlining the change(s) made in the PR should be written under the `## Upcoming Release` header in the past tense. Add changelog in description section if PR goes into [`generation`](https://github.com/Azure/azure-powershell/tree/generation) branch.
* Should **not** change `ChangeLog.md` if no new release is required, such as fixing test case only.
* **SHOULD** have approved design review for the changes in [this repository](https://github.com/Azure/azure-powershell-cmdlet-review-pr) ([_Microsoft internal only_](../blob/main/CONTRIBUTING.md#onboarding)) with following situations
* Create new module from scratch
* Create new resource types which are not easy to conform to [Azure PowerShell Design Guidelines](../blob/main/documentation/development-docs/design-guidelines)
* Create new resource type which name doesn't use module name as prefix
* Have design question before implementation
* **SHOULD** regenerate markdown help files if there is cmdlet API change. [Instruction](../blob/main/documentation/development-docs/help-generation.md#updating-all-markdown-files-in-a-module)
* **SHOULD** have proper test coverage for changes in pull request.
* **SHOULD NOT** introduce [breaking changes](../blob/main/documentation/breaking-changes/breaking-changes-definition.md) in Az minor release except preview version.
* **SHOULD NOT** adjust version of module manually in pull request
'@
$RequestBody = @{"title" = "Sync tools code from main branch to generation branch"; "body" = $PrBody; "head" = "syncToolsFolder-generation"; "base" = "generation" }
Invoke-WebRequest -Uri https://api.github.com/repos/Azure/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json)
$Title = "Sync tools code from main branch to generation branch"
$HeadBranch = "syncToolsFolder-$(BranchName)"
$BaseBranch = "$(BranchName)"
$Description = "Migrate Sync tools code from main branch to $(BranchName) branch"
./tools/Github/CreatePR.ps1 -Title $Title -HeadBranch $HeadBranch -BaseBranch $BaseBranch -BotAccessToken $(GithubToken) -Description $Description
displayName: Create PR to generation branch
67 changes: 67 additions & 0 deletions tools/Github/CreatePR.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# ----------------------------------------------------------------------------------
#
# Copyright Microsoft Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Create PR to azure-powershell repo
#>
param(
[Parameter(Mandatory = $true)]
[string]$BotAccessToken,

[Parameter(Mandatory = $true)]
[string]$Title,

[Parameter(Mandatory = $true)]
[string]$HeadBranch,

[Parameter(Mandatory = $true)]
[string]$BaseBranch,

[Parameter(Mandatory = $false)]
[string]$Description
)

$Headers = @{"Accept" = "application/vnd.github+json"; "Authorization" = "Bearer $BotAccessToken"}
$PrBody = @"
<!-- DO NOT DELETE THIS TEMPLATE -->
## Description
$Description
<!-- Please add a brief description of the changes made in this PR. If you have an ongoing or finished cmdlet design, please paste the link below. -->
## Checklist
- [x] Check this box to confirm: **I have read the [_Submitting Changes_](../blob/main/CONTRIBUTING.md#submitting-changes) section of [`CONTRIBUTING.md`](../blob/main/CONTRIBUTING.md) and reviewed the following information:**
* **SHOULD** select appropriate branch. Cmdlets from Autorest.PowerShell should go to [`generation`](https://github.com/Azure/azure-powershell/tree/generation) branch.
* **SHOULD** make the title of PR clear and informative, and in the present imperative tense.
* **SHOULD** update `ChangeLog.md` file(s) appropriately
* For any service, the `ChangeLog.md` file can be found at `src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md`
* A snippet outlining the change(s) made in the PR should be written under the `## Upcoming Release` header in the past tense. Add changelog in description section if PR goes into [`generation`](https://github.com/Azure/azure-powershell/tree/generation) branch.
* Should **not** change `ChangeLog.md` if no new release is required, such as fixing test case only.
* **SHOULD** have approved design review for the changes in [this repository](https://github.com/Azure/azure-powershell-cmdlet-review-pr) ([_Microsoft internal only_](../blob/main/CONTRIBUTING.md#onboarding)) with following situations
* Create new module from scratch
* Create new resource types which are not easy to conform to [Azure PowerShell Design Guidelines](../blob/main/documentation/development-docs/design-guidelines)
* Create new resource type which name doesn't use module name as prefix
* Have design question before implementation
* **SHOULD** regenerate markdown help files if there is cmdlet API change. [Instruction](../blob/main/documentation/development-docs/help-generation.md#updating-all-markdown-files-in-a-module)
* **SHOULD** have proper test coverage for changes in pull request.
* **SHOULD NOT** introduce [breaking changes](../blob/main/documentation/breaking-changes/breaking-changes-definition.md) in Az minor release except preview version.
* **SHOULD NOT** adjust version of module manually in pull request
"@
$RequestBody = @{"title" = $Title; "body" = $PrBody; "head" = $HeadBranch; "base" = $BaseBranch }
Invoke-WebRequest -Uri https://api.github.com/repos/Azure/azure-powershell/pulls -method POST -Headers $Headers -Body ($RequestBody | ConvertTo-Json)

0 comments on commit 2a57296

Please sign in to comment.