Cherry-pick Labeled PR to Release Branch #1
This file contains 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: Cherry-pick Labeled PR to Release Branch | |
on: | |
workflow_dispatch | |
permissions: write-all | |
jobs: | |
cherrypick_to_release: | |
name: cherrypick_to_release | |
runs-on: ubuntu-latest | |
# if: | | |
# (github.event.label.name == format('cp{0} beta', ':') || github.event.label.name == format('cp{0} beta', ':')) && | |
# (github.event.pull_request.merged == true) | |
steps: | |
- name: Get Release Channel | |
run: | | |
# echo "CHANNEL=$(echo ${{ github.event.label.name }} | cut -d ':' -f 2 | xargs)" >> $GITHUB_ENV | |
echo "CHANNEL=beta" >> $GITHUB_ENV | |
- name: Get Release Candidate Branch | |
run: | | |
curl -o version.json https://raw.githubusercontent.com/flutter/flutter/$CHANNEL/bin/internal/release-candidate-branch.version | |
echo "RELEASE_BRANCH=$(cat version.json | tr -d '\n')" >> $GITHUB_ENV | |
rm version.json | |
- name: Get Cherry Pick PR | |
run: | | |
# echo "COMMIT_SHA=$(echo ${{ github.event.pull_request.merge_commit_sha }})" >> $GITHUB_ENV | |
echo "COMMIT_SHA=cf71a55f7d1613dd1795c68cd799c18900caa39a" >> $GITHUB_ENV | |
- name: Checkout Flutter Repo | |
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 | |
with: | |
ref: ${{ env.RELEASE_BRANCH }} | |
repository: flutter/flutter | |
token: ${{ github.token }} | |
path: flutter | |
# use same name when checking out branch, since the marketplace action does a hard reset. | |
- name: Attempt CP | |
id: attempt-cp | |
run: | | |
git --version | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
git checkout -b $RELEASE_BRANCH --track origin/$RELEASE_BRANCH | |
git cherry-pick $COMMIT_SHA | |
git status | |
# TODO(xilaizhang): remove this on PR submission | |
- name: Get CP Template | |
run: | | |
curl -o flutter/.github/workflows/cp_template.yaml https://cs.opensource.google/flutter/flutter/+/master:.github/ISSUE_TEMPLATE/7_cherry_pick.yml | |
- name: Create PR on CP success | |
if: ${{ steps.attempt-cp.conclusion == 'success' }} | |
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 | |
with: | |
token: ${{ github.token }} | |
commit-message: automated cherry pick | |
committer: GitHub <[email protected]> | |
title: '[$RELEASE_BRANCH-cp] Cherry pick ${{ github.event.pull_request.title }}' | |
body-path: ./github/workflows/cp_template.yml | |
- name: Leave Comment on CP failure | |
if: ${{ steps.attempt-cp.conclusion == 'failure' }} | |
run: | | |
FAILURE_MSG = "An automated cherry pick for this PR was attempted due to the cherry pick label added.<br>" | |
FAILURE_MSG += "However, the cherry pick failed (potentially due to a merge confclit).<br>" | |
FAILURE_MSG += "You will need to create the cherry pick PR pull request manually and add chillers as a reviewer.<br>" | |
gh pr comment 3305 -R flutter/cocoon -b $FAILURE_MSG | |