Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Add comment notifications for cherry-pick workflow (#4375)
Browse files Browse the repository at this point in the history
- Add a comment if cherry-pick workflow operation was succesful, failed
  or cancelled
- Links the created PR if successful
- Update docs

Signed-off-by: Navid Shaikh <navids@vmware.com>
  • Loading branch information
navidshaikh authored Feb 14, 2023
1 parent 0c0f23e commit af08710
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
41 changes: 39 additions & 2 deletions .github/workflows/cherry-pick.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: Cherry-pick

on:
pull_request:
branches:
Expand All @@ -7,15 +9,18 @@ on:
jobs:
cherry_pick_release_v0_28:
runs-on: ubuntu-latest
name: Cherry pick into release-0.28 brach
name: Cherry-pick into release-0.28 brach
if: ${{ contains(github.event.pull_request.labels.*.name, 'cherry-pick/release-0.28') && github.event.pull_request.merged == true }}
outputs:
pr_url: ${{ steps.cherrypick.outputs.html_url }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cherry pick into release-0.28
uses: carloscastrojumo/github-cherry-pick-action@v1.0.6
id: cherrypick
uses: carloscastrojumo/github-cherry-pick-action@v1.0.9
with:
token: ${{ secrets.ALFRED_PAT }}
committer: Alfred the Narwhal <noreply@github.com>
Expand All @@ -24,3 +29,35 @@ jobs:
title: '[release-0.28] cherry-pick ${{github.event.number}} : {old_title}'
body: 'Cherry-pick of #{old_pull_request_id} into release-0.28 branch'
labels: "backports/release-0.28"
notify_cherrypick_status:
runs-on: ubuntu-latest
name: Notify release-0.28 cherry-pick status
needs: [cherry_pick_release_v0_28]
if: always()
steps:
- id: check
uses: martialonline/workflow-status@v3
- name: post failure message
uses: peter-evans/create-or-update-comment@v2
if: steps.check.outputs.status == 'failure'
with:
token: ${{ secrets.ALFRED_PAT }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Failed to create cherry-pick PR, workflow failed (usually due to merge conflicts), please create the cherry-pick PR manually.
- name: post success message
uses: peter-evans/create-or-update-comment@v2
if: steps.check.outputs.status == 'success'
with:
token: ${{ secrets.ALFRED_PAT }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Created cherry-pick PR ${{ needs.cherry_pick_release_v0_28.outputs.pr_url }}
- name: post cancelled workflow message
uses: peter-evans/create-or-update-comment@v2
if: steps.check.outputs.status == 'cancelled'
with:
token: ${{ secrets.ALFRED_PAT }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Cherry-pick workflow is cancelled, please re-run the workflow manually.
4 changes: 2 additions & 2 deletions docs/release/cherry-pick.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Cherry-pick process
- Know the target release branches your PR must be cherry-picked into
- Raise your PR against main branch and add label `cherry-pick/release-0.28` where `release-0.28` is branch name, where you'd like to cherry-pick this change
- Get your PR against main tested, reviewed and merged. Once merged, github action workflow will create cherry-pick PR against desired release branch.
- You can specify multiple labels for multiple cherry-pick PRs, just add respective labels for example: `cherry-pick/release-0.28` `cherry-pick/release-0.29`
- The workflow expects no conflicts while raising cherry-pick PRs, otherwise you'll have to create the cherry-picks manually. Monitor the workflow in your original PR against main for success/failure.
- The workflow adds a comment on the PR about the status of cherry-pick workflow for success (comment the resulting cherry-pick PR), failure or cancelled (if workflow is cancelled).
- If there are merge conflicts while raising the cherry-pick PR, the workflow fails and adds respective comment on the merged PR. In this case, please raise the cherry-pick PR manually.

0 comments on commit af08710

Please # to comment.