-
Notifications
You must be signed in to change notification settings - Fork 263
59 lines (56 loc) · 2.35 KB
/
backport-pr-manual.yml
File metadata and controls
59 lines (56 loc) · 2.35 KB
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
name: 'Manually Cherry-Pick to Release Branches'
on:
workflow_dispatch:
inputs:
merge_commit_sha:
description: 'The sha of the merge commit from the main PR.'
required: true
env :
TERRAFORM_MAINTAINERS: ${{ vars.TERRAFORM_MAINTAINERS }} # eg. ["matttrach"]
jobs:
create-cherry-pick-prs:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
actions: write
steps:
- name: 'Wait for merge to settle'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 https://github.com/actions/github-script
env:
MERGE_COMMIT_SHA: ${{ inputs.merge_commit_sha }}
TERRAFORM_MAINTAINERS: ${{ env.TERRAFORM_MAINTAINERS }}
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const mergeCommitSha = process.env.MERGE_COMMIT_SHA;
// wait 10 seconds to allow GitHub to index the commit and associated PRs
await new Promise(resolve => setTimeout(resolve, 10000));
// just in case the GitHub API is still having trouble, try to fetch associated PRs
let response;
try {
response = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner,
repo,
commit_sha: mergeCommitSha
});
} catch (error) {
core.setFailed(`Failed to retrieve PRs associated with commit ${mergeCommitSha}: ${error.message}`);
}
- name: 'Checkout Repository'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 https://github.com/actions/checkout
with:
fetch-depth: 0
ref: 'main'
- name: 'Find Issues and Create Cherry-Pick PRs'
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 https://github.com/actions/github-script
env:
MERGE_COMMIT_SHA: ${{ inputs.merge_commit_sha }}
TERRAFORM_MAINTAINERS: ${{ env.TERRAFORM_MAINTAINERS }}
with:
script: |
const scriptPath = `${process.env.GITHUB_WORKSPACE}/.github/workflows/scripts/backport-pr.js`;
const { default: script } = await import(scriptPath);
await script({github, core, process});