Skip to content

Commit

Permalink
updating the github actions across the nailgun (#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
omkarkhatavkar authored Nov 24, 2022
1 parent 28cd2af commit 42c9bab
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 7 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 to create the gh issue in case of failed auto-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
43 changes: 38 additions & 5 deletions .github/workflows/auto_cherry_pick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,68 @@ 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')
needs: previous-branch
runs-on: ubuntu-latest
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 }}
branch: ${{ env.TO_BRANCH }}
labels: |
Auto_Cherry_Picked
${{ 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:
- name: Create Issue on Failed Auto Cherrypick
uses: dacbd/create-issue-action@main
- uses: dacbd/create-issue-action@main
id: create_issue
with:
token: ${{ secrets.CHERRYPICK_PAT }}
title: "[Failed-AutoCherryPick] - ${{ github.event.pull_request.title }}"
Expand All @@ -63,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 - Nailgun
uses: Co-qn/google-chat-notification@releases/v1
uses: omkarkhatavkar/google-chat-notification@master
with:
name: "${{ github.event.pull_request.title }}"
url: ${{ secrets.GCHAT_REVIEWERS_WEBHOOK }}
issue_url: ${{ needs.create-issue.outputs.issue_url }}
status: failure
31 changes: 31 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
#
# You can adjust the behavior by modifying this file.
# For more information, see:
# https://github.com/actions/stale
name: Warn and Close stale issues and pull requests

on:
schedule:
- cron: '30 5 * * *'

jobs:
warn_and_close_stails:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v6
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-issue-stale: 90
days-before-pr-stale: 45
days-before-issue-close: 7
days-before-pr-close: 7
stale-issue-message: 'This issue has not been updated in the past 90 days.'
stale-pr-message: 'This pull request has not been updated in the past 45 days.'
close-issue-message: 'This issue is now being closed after stale warnings.'
close-pr-message: 'This pull request is now being closed after stale warnings.'
only-issue-labels: 'Failed_AutoCherryPick'
remove-stale-when-updated: true
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
rev: 22.3.0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
Expand Down

0 comments on commit 42c9bab

Please sign in to comment.