Skip to content

Commit

Permalink
Alligning ACP GHA with Robottelo (#780) (#782)
Browse files Browse the repository at this point in the history
Co-authored-by: Jitendra Yejare <jyejare@redhat.com>
  • Loading branch information
Satellite-QE and jyejare committed Nov 16, 2022
1 parent 4cf2614 commit 4fec815
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/auto_assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addAssignees: author
21 changes: 21 additions & 0 deletions .github/workflows/auto_assignment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'Auto Assign'

on:
pull_request_target:
types:
- opened
- ready_for_review
- reopened
- synchronize


jobs:
add-assignees: # This needed 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
steps:
- uses: kentaro-m/auto-assign-action@v1.2.4
with:
repo-token: "${{ secrets.CHERRYPICK_PAT || github.token }}"
configuration-path: ".github/auto_assign.yml"
46 changes: 40 additions & 6 deletions .github/workflows/auto_cherry_pick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,57 @@ jobs:
with:
fetch-depth: 0
- id: set-branch
run: echo "::set-output name=previous_branch::$(if [ $GITHUB_BASE_REF == 'master' ]; then echo $(git branch -rl 'origin/6.*.z' --format='%(refname:lstrip=-1)' | sort --version-sort | tail -n1 | jq -cnR '[inputs | select(length>0)]'); else echo ['"6.'$(($(echo $GITHUB_BASE_REF | cut -d. -f2) - 1))'.z"']; fi)"
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

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')
needs: previous-branch
runs-on: ubuntu-latest
strategy:
matrix:
to_branch: ${{ fromJson(needs.previous-branch.outputs.previous_branch) }}
env:
TO_BRANCH: ${{ needs.previous-branch.outputs.previous_branch }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cherry pick into ${{ matrix.to_branch }}
- name: Cherry pick into ${{ env.TO_BRANCH }}
uses: jyejare/github-cherry-pick-action@main
with:
branch: ${{ matrix.to_branch }}
token: ${{ secrets.CHERRYPICK_PAT }}
branch: ${{ env.TO_BRANCH }}
labels: |
Auto_Cherry_Picked
${{ env.TO_BRANCH }}
assignees: "${{ github.event.pull_request.assignee.login }}"

create-issue:
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 }}
steps:
- name: Create Issue on Failed Auto Cherrypick
uses: dacbd/create-issue-action@main
with:
token: ${{ secrets.CHERRYPICK_PAT }}
title: "[Failed-AutoCherryPick] - ${{ github.event.pull_request.title }}"
body: |
#### Auto-Cherry-Pick WorkFlow Failure:
- To Branch: ${{ env.TO_BRANCH }}
- [Failed Cherrypick Action](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
- [Parent Pull Request](https://github.com/${{ github.repository }}/pull/${{ github.event.number }})
labels: Failed_AutoCherryPick,${{ env.TO_BRANCH }}
assignees: "${{ github.event.pull_request.assignee.login }}"

google-chat-notification:
runs-on: ubuntu-latest
if: ${{ always() && contains(join(needs.*.result, ','), 'failure') }}
needs: auto-cherry-pick
steps:
- name: Google Chat Notification - Airgun
uses: Co-qn/google-chat-notification@releases/v1
with:
name: "${{ github.event.pull_request.title }}"
url: ${{ secrets.GCHAT_REVIEWERS_WEBHOOK }}
status: failure

0 comments on commit 4fec815

Please sign in to comment.