diff --git a/.github/workflows/backport-base.yml b/.github/workflows/backport-base.yml index 13178ce38b..8518144320 100644 --- a/.github/workflows/backport-base.yml +++ b/.github/workflows/backport-base.yml @@ -164,74 +164,74 @@ jobs: // download and apply patch await exec.exec(`curl -sSL "${context.payload.issue.pull_request.patch_url}" --output changes.patch`); - const git_am_command = "git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch"; - let git_am_output = `$ ${git_am_command}\n\n`; - let git_am_failed = false; - try { - await exec.exec(git_am_command, [], { - listeners: { - stdout: function stdout(data) { git_am_output += data; }, - stderr: function stderr(data) { git_am_output += data; } - } - }); - } catch (error) { - git_am_output += error; - git_am_failed = true; - } + // const git_am_command = "git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch"; + // let git_am_output = `$ ${git_am_command}\n\n`; + // let git_am_failed = false; + // try { + // await exec.exec(git_am_command, [], { + // listeners: { + // stdout: function stdout(data) { git_am_output += data; }, + // stderr: function stderr(data) { git_am_output += data; } + // } + // }); + // } catch (error) { + // git_am_output += error; + // git_am_failed = true; + // } - if (git_am_failed) { - const git_am_failed_body = `@${context.payload.comment.user.login} backporting to ${target_branch} failed, the patch most likely resulted in conflicts:\n\n\`\`\`shell\n${git_am_output}\n\`\`\`\n\nPlease backport manually!`; - await github.rest.issues.createComment({ - owner: repo_owner, - repo: repo_name, - issue_number: pr_number, - body: git_am_failed_body - }); - core.setFailed("Error: git am failed, most likely due to a merge conflict."); - return; - } - else { - // push the temp branch to the repository - await exec.exec(`git push --force --set-upstream origin HEAD:${temp_branch}`); - } + // if (git_am_failed) { + // const git_am_failed_body = `@${context.payload.comment.user.login} backporting to ${target_branch} failed, the patch most likely resulted in conflicts:\n\n\`\`\`shell\n${git_am_output}\n\`\`\`\n\nPlease backport manually!`; + // await github.rest.issues.createComment({ + // owner: repo_owner, + // repo: repo_name, + // issue_number: pr_number, + // body: git_am_failed_body + // }); + // core.setFailed("Error: git am failed, most likely due to a merge conflict."); + // return; + // } + // else { + // // push the temp branch to the repository + // await exec.exec(`git push --force --set-upstream origin HEAD:${temp_branch}`); + // } - if (!should_open_pull_request) { - console.log("Backport temp branch already exists, skipping opening a PR."); - return; - } + // if (!should_open_pull_request) { + // console.log("Backport temp branch already exists, skipping opening a PR."); + // return; + // } // prepare the GitHub PR details // get users to cc (append PR author if different from user who issued the backport command) - let cc_users = `@${comment_user}`; - if (comment_user != context.payload.issue.user.login) cc_users += ` @${context.payload.issue.user.login}`; + // let cc_users = `@${comment_user}`; + // if (comment_user != context.payload.issue.user.login) cc_users += ` @${context.payload.issue.user.login}`; // replace the special placeholder tokens with values - const { BACKPORT_PR_TITLE_TEMPLATE, BACKPORT_PR_DESCRIPTION_TEMPLATE } = process.env + // const { BACKPORT_PR_TITLE_TEMPLATE, BACKPORT_PR_DESCRIPTION_TEMPLATE } = process.env - const backport_pr_title = BACKPORT_PR_TITLE_TEMPLATE - .replace(/%target_branch%/g, target_branch) - .replace(/%source_pr_title%/g, context.payload.issue.title) - .replace(/%source_pr_number%/g, context.payload.issue.number) - .replace(/%cc_users%/g, cc_users); + // const backport_pr_title = BACKPORT_PR_TITLE_TEMPLATE + // .replace(/%target_branch%/g, target_branch) + // .replace(/%source_pr_title%/g, context.payload.issue.title) + // .replace(/%source_pr_number%/g, context.payload.issue.number) + // .replace(/%cc_users%/g, cc_users); - const backport_pr_description = BACKPORT_PR_DESCRIPTION_TEMPLATE - .replace(/%target_branch%/g, target_branch) - .replace(/%source_pr_title%/g, context.payload.issue.title) - .replace(/%source_pr_number%/g, context.payload.issue.number) - .replace(/%cc_users%/g, cc_users); + // const backport_pr_description = BACKPORT_PR_DESCRIPTION_TEMPLATE + // .replace(/%target_branch%/g, target_branch) + // .replace(/%source_pr_title%/g, context.payload.issue.title) + // .replace(/%source_pr_number%/g, context.payload.issue.number) + // .replace(/%cc_users%/g, cc_users); // open the GitHub PR - await github.rest.pulls.create({ - owner: repo_owner, - repo: repo_name, - title: backport_pr_title, - body: backport_pr_description, - head: temp_branch, - base: target_branch - }); + // await github.rest.pulls.create({ + // owner: repo_owner, + // repo: repo_name, + // title: backport_pr_title, + // body: backport_pr_description, + // head: temp_branch, + // base: target_branch + // }); - console.log("Successfully opened the GitHub PR."); + // console.log("Successfully opened the GitHub PR."); } catch (error) { core.setFailed(error); @@ -246,6 +246,11 @@ jobs: }); } + - uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v7 + with: + token: ${{ secrets.BACKPORT_MACHINE_USER_PAT }} + push-to-fork: youssef-backport-bot/testfx + - name: Re-lock PR comments uses: actions/github-script@v7 if: ${{ github.event.issue.locked == true && (success() || failure()) }} diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 8f8e3af3d7..f0a13576ad 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -20,4 +20,4 @@ jobs: pr_description_template: | Backport of #%source_pr_number% to %target_branch% - /cc %cc_users% \ No newline at end of file + /cc %cc_users%