Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment on cherry pick PR on failure #524

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions .github/workflows/label-cherry-pick.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,21 @@ jobs:
git config --global user.email "[email protected]"

- name: Cherry pick merge commit
id: cherry-pick
run: |
set -e
git fetch origin ${{ matrix.target_branch }}
set +e
git cherry-pick -x $MERGE_COMMIT_SHA
RES=$?
set -e
if [ $RES -eq 0 ]; then
echo "CREATE_PR_AS_DRAFT=false" >> $GITHUB_ENV
else
echo "CREATE_PR_AS_DRAFT=true" >> $GITHUB_ENV
git add .
git cherry-pick --continue
fi
git add .
git cherry-pick --continue

- name: Create Pull Request
id: create-pr
if: always()
uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04 # v4.2.3
with:
token: ${{ secrets.CHERRY_PICK_TOKEN }}
draft: ${{ env.CREATE_PR_AS_DRAFT }}
draft: ${{ steps.cherry-pick.outcome == 'failure' }}
base: ${{ matrix.target_branch }}
branch: "${{ matrix.target_branch }}-${{ github.event.pull_request.number }}"
committer: GitHub Release Automation <[email protected]>
Expand All @@ -99,3 +95,15 @@ jobs:
Refer to the original PR: https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}

${{ github.event.pull_request.body }}
- name: PR Comment
if: failure() && steps.create-pr.outputs.pull-request-number
uses: actions/github-script@v2
with:
github-token: ${{ secrets.CHERRY_PICK_TOKEN }}
script: |
github.issues.createComment({
issue_number: ${{ steps.create-pr.outputs.pull-request-number }},
owner: context.repo.owner,
repo: context.repo.repo,
body: '[!IMPORTANT]\nThe cherry-pick failed! Check out the PR branch (${{ matrix.target_branch }}-${{ github.event.pull_request.number }}) and fix the conflicts before proceeding.'
})
Loading