diff --git a/.github/workflows/auto_assignment.yaml b/.github/workflows/auto_assignment.yaml index 5c4da31b09e..e9249887fb9 100644 --- a/.github/workflows/auto_assignment.yaml +++ b/.github/workflows/auto_assignment.yaml @@ -10,7 +10,7 @@ on: jobs: - add-assignees: # This needed for to create the gh issue in case of failed auto0-cherry-pick + add-assignees: # This needed for to create the gh issue in case of failed auto-cherry-pick name: Add author to assignee if: "!contains(github.event.pull_request.labels.*.name, 'Auto_Cherry_Picked')" runs-on: ubuntu-latest diff --git a/.github/workflows/auto_cherry_pick.yml b/.github/workflows/auto_cherry_pick.yml index 5494a68490b..a5cd80aaae5 100644 --- a/.github/workflows/auto_cherry_pick.yml +++ b/.github/workflows/auto_cherry_pick.yml @@ -20,6 +20,20 @@ jobs: - id: set-branch run: echo "previous_branch=$(if [ $GITHUB_BASE_REF == 'master' ]; then echo $(git branch -rl 'origin/6.*.z' --format='%(refname:lstrip=-1)' | sort --version-sort | tail -n1); else echo '6.'$(($(echo $GITHUB_BASE_REF | cut -d. -f2) - 1))'.z'; fi)" >> $GITHUB_OUTPUT + find-the-parent-prt-comment: + name: Find & Save last PRT comment of Parent PR + runs-on: ubuntu-latest + outputs: + prt_comment: ${{steps.fc.outputs.comment-body}} + steps: + - name: Find Comment + uses: peter-evans/find-comment@v2 + id: fc + with: + issue-number: ${{ github.event.number }} + body-includes: "trigger: test-robottelo" + direction: last + auto-cherry-pick: name: Auto Cherry Pick to previous branch if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'CherryPick') @@ -28,12 +42,15 @@ jobs: env: PR_AUTHOR: ${{ github.event.pull_request.user.login }} TO_BRANCH: ${{ needs.previous-branch.outputs.previous_branch }} + outputs: + pr_number: ${{steps.issue.outputs.number}} steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Cherry pick into ${{ env.TO_BRANCH }} uses: jyejare/github-cherry-pick-action@main + id: issue with: author: ${{ env.PR_AUTHOR }} <${{ env.PR_AUTHOR }}@users.noreply.github.com> token: ${{ secrets.CHERRYPICK_PAT }} @@ -43,6 +60,16 @@ jobs: ${{ env.TO_BRANCH }} assignees: "${{ github.event.pull_request.assignee.login }}" + add-parent-prt-comment: + name: Add Parent PR's PRT comment to Auto_Cherry_Picked PR's + runs-on: ubuntu-latest + needs: [ auto-cherry-pick, find-the-parent-prt-comment ] + steps: + - uses: mshick/add-pr-comment@v2 + with: + issue: ${{ needs.auto-cherry-pick.outputs.pr_number }} + message: ${{needs.find-the-parent-prt-comment.outputs.prt_comment}} + create-issue: name: Create Github issue on cherrypick failure runs-on: ubuntu-latest @@ -50,8 +77,11 @@ jobs: needs: [previous-branch, auto-cherry-pick] env: TO_BRANCH: ${{ needs.previous-branch.outputs.previous_branch }} + outputs: + issue_url: ${{steps.create_issue.outputs.html_url}} steps: - uses: dacbd/create-issue-action@main + id: create_issue with: token: ${{ secrets.CHERRYPICK_PAT }} title: "[Failed-AutoCherryPick] - ${{ github.event.pull_request.title }}" @@ -65,12 +95,13 @@ jobs: google-chat-notification: runs-on: ubuntu-latest - if: ${{ always() && contains(join(needs.*.result, ','), 'failure') }} - needs: auto-cherry-pick + if: ${{ always() && contains(join(needs.auto-cherry-pick.result, ','), 'failure') }} + needs: [auto-cherry-pick, create-issue] steps: - name: Google Chat Notification - Robottelo - uses: Co-qn/google-chat-notification@releases/v1 + uses: omkarkhatavkar/google-chat-notification@main with: name: "${{ github.event.pull_request.title }}" url: ${{ secrets.GCHAT_REVIEWERS_WEBHOOK }} + issue_url: ${{ needs.create-issue.outputs.issue_url }} status: failure