Skip to content

Commit

Permalink
Cherry pick worflow: improve message after conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Jun 25, 2024
1 parent e618232 commit 9283411
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion .github/workflows/cherry-pick-wp-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
git cherry-pick $COMMIT_SHA || echo "cherry-pick-failed" > result
if [ -f result ] && grep -q "cherry-pick-failed" result; then
echo "conflict=true" >> $GITHUB_ENV
echo "commit_sha=$COMMIT_SHA" >> $GITHUB_ENV
git cherry-pick --abort
else
NEW_COMMIT_SHA=$(git rev-parse HEAD)
Expand Down Expand Up @@ -122,12 +123,32 @@ jobs:
with:
script: |
const prNumber = context.issue.number;
const commitSha = process.env.commit_sha;
const targetBranch = `wp/${process.env.version}`;
console.log(`prNumber: ${prNumber}`);
console.log(`targetBranch: ${targetBranch}`);
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `There was a conflict while trying to cherry-pick the commit to the ${targetBranch} branch. Please resolve the conflict manually and create a PR to the ${targetBranch} branch.`
body: `There was a conflict while trying to cherry-pick the commit to the ${targetBranch} branch. Please resolve the conflict manually and create a PR to the ${targetBranch} branch.
PRs to ${targetBranch} are similar to PRs to trunk, but you should base your PR on the ${targetBranch} branch instead of trunk.
\`\`\`
# Checkout the ${targetBranch} branch instead of trunk.
git checkout ${targetBranch}
# Create a new branch for your PR.
git checkout -b my-branch
# Cherry-pick the commit.
git cherry-pick ${commitSha}
# Resolve the conflict...
git add .
git cherry-pick --continue
# Push the branch to the repository
git push origin my-branch
# Create a PR and set the base to the ${targetBranch} branch.
# See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request.
\`\`\`
`
});

0 comments on commit 9283411

Please sign in to comment.