Skip to content

Commit

Permalink
[GHA]:Added support to copy the PRT comment in auto-cherry-pick pr's (#…
Browse files Browse the repository at this point in the history
…10308)

* [GHA]:Added support to copy the PRT comment in auto-cherry-pick pr's

* added support for the adding the author name and issue link g-chat notification
  • Loading branch information
omkarkhatavkar authored Nov 21, 2022
1 parent f36ad74 commit 621b453
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto_assignment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 34 additions & 3 deletions .github/workflows/auto_cherry_pick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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 }}
Expand All @@ -43,15 +60,28 @@ 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
if: ${{ always() && contains(join(needs.*.result, ','), 'failure') }}
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 }}"
Expand All @@ -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

0 comments on commit 621b453

Please sign in to comment.