diff --git a/.github/workflows/auto_assignment.yaml b/.github/workflows/auto_assignment.yaml index 328e4bf6..e9249887 100644 --- a/.github/workflows/auto_assignment.yaml +++ b/.github/workflows/auto_assignment.yaml @@ -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 diff --git a/.github/workflows/auto_cherry_pick.yml b/.github/workflows/auto_cherry_pick.yml index 12ac9d0d..bc7a5ec4 100644 --- a/.github/workflows/auto_cherry_pick.yml +++ b/.github/workflows/auto_cherry_pick.yml @@ -20,20 +20,39 @@ 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: | @@ -41,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: - - 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 }}" @@ -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 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 00000000..66b30c2f --- /dev/null +++ b/.github/workflows/stale.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c482f053..ed9dbb96 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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