Welcome to mirror list, hosted at ThFree Co, Russian Federation.

backport.yml « workflows « .github - github.com/dotnet/aspnetcore.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3c87042454f46a9268a91aa13b5f5f6fb7c675f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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.rest.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: ./eng/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%

          # {PR title}

          Summary of the changes (Less than 80 chars)

          ## Description

          {Detail}

          Fixes #{bug number} (in this specific format)

          ## Customer Impact

          {Justification}

          ## Regression?

          - [ ] Yes
          - [ ] No

          [If yes, specify the version the behavior has regressed from]

          ## Risk

          - [ ] High
          - [ ] Medium
          - [ ] Low

          [Justify the selection above]

          ## Verification

          - [ ] Manual (required)
          - [ ] Automated

          ## Packaging changes reviewed?

          - [ ] Yes
          - [ ] No
          - [ ] N/A

          ----

          ## When servicing release/2.1

          - [ ] Make necessary changes in eng/PatchConfig.props