From d665b84c05c8549529cce70fecfc3147b7cc3a30 Mon Sep 17 00:00:00 2001 From: "tao.yang" Date: Tue, 27 Feb 2024 11:22:32 +0800 Subject: [PATCH] automatically port the label from the initial cherry-picked PR Signed-off-by: tao.yang --- .github/workflows/auto-cherry-pick.yaml | 20 ++++++++++++++++--- .github/workflows/call-release-changelog.yaml | 8 ++++++++ .github/workflows/call-release-chart.yaml | 8 ++++++++ .github/workflows/call-release-pages.yaml | 8 ++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/.github/workflows/auto-cherry-pick.yaml b/.github/workflows/auto-cherry-pick.yaml index e2d4ba8b..501cbd21 100644 --- a/.github/workflows/auto-cherry-pick.yaml +++ b/.github/workflows/auto-cherry-pick.yaml @@ -30,6 +30,13 @@ jobs: with: fetch-depth: 0 + - uses: crazy-max/ghaction-import-gpg@v5 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + # ${{ secrets.GITHUB_TOKEN }} is forbidden to create or approve pull requests - name: cherry pick env: @@ -90,25 +97,31 @@ jobs: # echo "=============================== get dest branch from labels ======== " WANT_MERGE_BRANCH_LIST="" + INITIAL_LABEL="" if ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.destBranch != '' }}; then WANT_MERGE_BRANCH_LIST=${{ github.event.inputs.destBranch }} else for LABEL in ${PR_LABEL} ; do echo "checking label $LABEL " PREFIX="${{ env.PR_LABEL_PREFIX_CHERRYPICK }}" - grep -E "^${PREFIX}" <<< "${LABEL}" &>/dev/null || continue + if ! grep -E "^${PREFIX}" <<< "${LABEL}" &>/dev/null; then + INITIAL_LABEL+="${LABEL}," + continue + fi BRANCH_NAME=` sed 's?'"${PREFIX}"'??' <<< "$LABEL" ` WANT_MERGE_BRANCH_LIST+=" $BRANCH_NAME " done fi [ -z "$WANT_MERGE_BRANCH_LIST" ] && echo "no branch to cherry pick" && exit 0 echo "cherry pick to $WANT_MERGE_BRANCH_LIST " + INITIAL_LABEL="${INITIAL_LABEL%,}" + echo "INITIAL_LABEL: ${INITIAL_LABEL}" # # echo "============ begin to cherry pick ============ " FINAL_FAILURE=false git branch - git config user.email "robot@example.com" + git config user.email "tao.yang@daocloud.io" git config user.name "robot" gh label create ${{ env.CHERRYPICK_LABEL }} || true for BRANCH in $WANT_MERGE_BRANCH_LIST ; do @@ -185,10 +198,11 @@ jobs: if [ "$UPDATE" == "true" ] ; then echo "succeeded to cherry pick to branch $BRANCH " # create a pr + git commit -s -S --amend --no-edit git push origin ${PR_BRANCH}:${PR_BRANCH} -f gh pr create --title "${PR_TITLE}" \ --assignee "${PR_AUTHOR},${{ env.DEFAULT_REVIEWER }}" \ - --label ${{ env.CHERRYPICK_LABEL }} \ + --label "${{ env.CHERRYPICK_LABEL }},${INITIAL_LABEL}" \ --body "robot cherry pick pr <${PR_URL}> to branch ${BRANCH}, action <${ACTION_URL}> , commits $PR_COMMITS " \ --base ${BRANCH} else diff --git a/.github/workflows/call-release-changelog.yaml b/.github/workflows/call-release-changelog.yaml index 7da81638..fb4ff560 100644 --- a/.github/workflows/call-release-changelog.yaml +++ b/.github/workflows/call-release-changelog.yaml @@ -131,6 +131,13 @@ jobs: name: changelog_artifact path: ${{ env.DEST_DIRECTORY }} + - uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + - name: Create Pull Request id: create_pr uses: peter-evans/create-pull-request@v5.0.2 @@ -138,6 +145,7 @@ jobs: title: "robot update changelog with tag ${{ needs.generate_changelog.outputs.dest_tag }} to branch ${{ env.DEST_BRANCH }} " commit-message: "robot update changelog from tag ${{ needs.generate_changelog.outputs.begin_tag }} to tag ${{ needs.generate_changelog.outputs.dest_tag }} " branch-suffix: timestamp + committer: ty-dc branch: robot/update_changelog delete-branch: true base: ${{ env.DEST_BRANCH }} diff --git a/.github/workflows/call-release-chart.yaml b/.github/workflows/call-release-chart.yaml index 76e8a74e..87608844 100644 --- a/.github/workflows/call-release-chart.yaml +++ b/.github/workflows/call-release-chart.yaml @@ -106,6 +106,13 @@ jobs: helm repo index ./charts --url ${url}/charts mv ./charts/index.yaml ./index.yaml + - uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + # Allow auto-merge on general - name: Create Pull Request id: create_pr @@ -115,6 +122,7 @@ jobs: commit-message: "robot update chart from ${{ needs.package.outputs.REF }} to branch ${{ env.MERGE_BRANCH }} " branch-suffix: timestamp branch: robot/update_doc + committer: ty-dc delete-branch: true base: ${{ env.MERGE_BRANCH }} signoff: true diff --git a/.github/workflows/call-release-pages.yaml b/.github/workflows/call-release-pages.yaml index 4b704374..3a1bd370 100644 --- a/.github/workflows/call-release-pages.yaml +++ b/.github/workflows/call-release-pages.yaml @@ -162,6 +162,13 @@ jobs: tar -xzvf site.tar.gz rm -f site.tar.gz + - uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + # Allow auto-merge on general - name: Create Pull Request id: create_pr @@ -171,6 +178,7 @@ jobs: commit-message: "robot update website from ${{ needs.package.outputs.ref }} to branch ${{ env.MERGE_BRANCH }} with tag ${{ needs.package.outputs.doc_tag }}" branch-suffix: timestamp branch: robot/update_doc + committer: ty-dc delete-branch: true base: ${{ env.MERGE_BRANCH }} signoff: true