| # Copyright 2023 The Cobalt Authors. All Rights Reserved. |
| # |
| # 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. |
| |
| # Usage: Go to |
| # https://https://github.com/youtube/cobalt/actions/workflows/manual-cherry-pick.yaml |
| # and click "Run Workflow." Leave "Use Workflow From" set to "main", then |
| # input the branch name and paste the cherry-pick commit and click Run. A PR |
| # will be created. |
| |
| name: Release Branch Cherrypick |
| on: |
| workflow_dispatch: |
| inputs: |
| # We use this instead of the "run on branch" argument because GitHub looks |
| # on that branch for a workflow.yml file, and we'd have to cherry-pick |
| # this file into those branches. |
| release_branch: |
| description: 'Release branch name (e.g. 23.lts.1+)' |
| required: true |
| type: string |
| git_commit: |
| description: 'Git commit to cherry-pick' |
| required: true |
| type: string |
| |
| jobs: |
| cherrypick: |
| name: Cherrypick to ${{ github.event.inputs.release_branch}} - ${{ github.event.inputs.git_commit }} |
| runs-on: ubuntu-latest |
| env: |
| ACCESS_TOKEN: ${{ secrets.CHERRY_PICK_TOKEN }} |
| RELEASE_BRANCH: ${{ github.event.inputs.release_branch }} |
| COMMIT_HASH: ${{ github.event.inputs.git_commit }} |
| REPOSITORY: ${{ github.repository }} |
| GITHUB_REF: ${{ github.ref }} |
| steps: |
| - name: Checkout code |
| uses: kaidokert/checkout@v3.5.999 |
| timeout-minutes: 30 |
| with: |
| ref: ${{ env.RELEASE_BRANCH }} |
| persist-credentials: false |
| - name: Get some helpful info for formatting |
| id: cherrypick |
| run: | |
| git config --global user.name "GitHub Release Automation" |
| git config --global user.email "github@google.com" |
| git fetch origin $GITHUB_REF |
| git cherry-pick -x $COMMIT_HASH |
| echo "SHORTSHA=$(git log -1 $COMMIT_HASH --format="%h")" >> "$GITHUB_OUTPUT" |
| echo "TITLE=$(git log -1 $COMMIT_HASH --format="%s")" >> "$GITHUB_OUTPUT" |
| - name: Create Pull Request with changes |
| uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04 # v4.2.3 |
| with: |
| title: '${{ env.RELEASE_BRANCH }} cherry-pick: ${{ steps.cherrypick.outputs.SHORTSHA }} "${{ steps.cherrypick.outputs.TITLE }}"' |
| committer: GitHub Release Automation <github@google.com> |
| token: ${{ secrets.CHERRY_PICK_TOKEN }} |
| base: ${{ env.RELEASE_BRANCH }} |
| branch: ${{ env.RELEASE_BRANCH }}-${{ steps.cherrypick.outputs.SHORTSHA }} |
| reviewers: ${{ github.actor }} |
| body: | |
| Refer to the original commit: https://github.com/${{ github.repository }}/commit/${{ github.event.inputs.git_commit }} |