-
Notifications
You must be signed in to change notification settings - Fork 121
73 lines (70 loc) · 3.08 KB
/
manual-cherry-pick.yaml
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
# 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: actions/checkout@v4
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 "[email protected]"
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 <[email protected]>
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 }}