From be4be30cc8b73f9b7ea1c66a194748b2c31c528d Mon Sep 17 00:00:00 2001 From: Xilai Zhang Date: Thu, 1 Feb 2024 15:34:44 -0800 Subject: [PATCH] [github actions] ping actor of workflow on cherry pick pr creation (#142676) Context: Follow up from sync with @itsjustkevin today. Tag and ping the actor of workflow, when the cherry pick pull request is successfully created. 1. actor of workflow will be the username of the user that triggered the initial workflow run. i.e., whoever labels the PR. This person might not necessarily be the author of the cherry pick PR. 2. PR number of newly created cherry pick PR is parsed from the output of "gh pr create" as a multi line string. Tested: on cp success: https://github.com/flutter/flutter/pull/142674 pings the actor of workflow (not the pr author). on cp failure: [example workflow](https://github.com/XilaiZhang/miscellaneous-side-project/actions/runs/7734400373/job/21088324523) leaves a msg on the original PR. --- .github/workflows/easy-cp.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/easy-cp.yml b/.github/workflows/easy-cp.yml index c10499f1c7a4c..738872428c8a7 100644 --- a/.github/workflows/easy-cp.yml +++ b/.github/workflows/easy-cp.yml @@ -57,12 +57,26 @@ jobs: - name: Create PR on CP success if: ${{ steps.attempt-cp.conclusion == 'success' }} working-directory: ./flutter + id: create-pr run: | git push https://${{ env.GITHUB_TOKEN }}@github.com/flutteractionsbot/flutter cp-${CHANNEL}-${COMMIT_SHA} - gh pr create --title "[CP-${CHANNEL}]${PR_TITLE}" --body-file ../PULL_REQUEST_CP_TEMPLATE.md --base ${RELEASE_BRANCH} --label "cp: review" --repo flutter/flutter --head flutteractionsbot:cp-${CHANNEL}-${COMMIT_SHA} + { + echo 'PR_URL<> "$GITHUB_ENV" env: GITHUB_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }} PR_TITLE: ${{ github.event.pull_request.title }} + - name: Leave Comment on CP success + if: ${{ steps.create-pr.conclusion == 'success' }} + run: | + echo $PR_URL + NEW_PR_NUMBER="${PR_URL##*/}" + SUCCESS_MSG=" @${{ github.actor }} please fill out the PR description above, afterwards the release team will review this request." + gh pr comment $NEW_PR_NUMBER -R flutter/flutter -b "${SUCCESS_MSG}" + env: + GITHUB_TOKEN: ${{ secrets.FLUTTERACTIONSBOT_CP_TOKEN }} - name: Leave Comment on CP failure if: ${{ failure() && steps.attempt-cp.conclusion == 'failure' }} run: |