Skip to content

Cherry-pick Labeled PR to Release Branch #11

Cherry-pick Labeled PR to Release Branch

Cherry-pick Labeled PR to Release Branch #11

Workflow file for this run

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=7d9010c3578338bc850d66c315bd6086f3d3dc9a" >> $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
working-directory: ./flutter
run: |
git --version
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git fetch origin master
git checkout -b cp-$COMMIT_SHA --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.yml 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:
path: flutter
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
# Need PAT Token to comment. Otherwise throws error "GraphQL: Resource not accessible by integration (addComment)"
- name: Leave Comment on CP failure
if: ${{ failure() && 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}"
env:
GITHUB_TOKEN: ${{ secrets.PAT }}