Manually Cherry-Pick to Release Branches #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 https://github.com/actions/checkout | |
| with: | |
| fetch-depth: 0 | |
| - 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 { default: script } = await import('./.github/workflows/scripts/backport-pr.js'); | |
| await script({github, core, process}); |