mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Add backport function to release tools (#19568)
* Add backport function * delete backport action
This commit is contained in:
committed by
Aditya Patwardhan
parent
f135ba4604
commit
6f37176bb9
@@ -1,61 +0,0 @@
|
||||
name: Backport PR to branch
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
backport:
|
||||
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/backport to')
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Extract backport target branch
|
||||
uses: actions/github-script@v6
|
||||
id: target-branch-extractor
|
||||
with:
|
||||
result-encoding: string
|
||||
script: |
|
||||
if (context.eventName !== "issue_comment") throw "Error: This action only works on issue_comment events.";
|
||||
|
||||
// extract the target branch name from the trigger phrase containing these characters: a-z, A-Z, digits, forward slash, dot, hyphen, underscore
|
||||
const regex = /^\/backport to ([a-zA-Z\d\/\.\-\_]+)/;
|
||||
target_branch = regex.exec(context.payload.comment.body);
|
||||
if (target_branch == null) throw "Error: No backport branch found in the trigger phrase.";
|
||||
|
||||
return target_branch[1];
|
||||
- name: Post backport started comment to pull request
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const backport_start_body = `Started backporting to ${{ steps.target-branch-extractor.outputs.result }}: https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${process.env.GITHUB_RUN_ID}`;
|
||||
await github.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: backport_start_body
|
||||
});
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Run backport
|
||||
uses: ./tools/actions/backport
|
||||
with:
|
||||
target_branch: ${{ steps.target-branch-extractor.outputs.result }}
|
||||
auth_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
pr_description_template: |
|
||||
Backport of #%source_pr_number% to %target_branch%
|
||||
|
||||
/cc %cc_users%
|
||||
|
||||
## Customer Impact
|
||||
|
||||
## Testing
|
||||
|
||||
- [ ] For any change that affects the release process, please work with a maintainer to come up with a plan to test this.
|
||||
|
||||
## Risk
|
||||
Reference in New Issue
Block a user