jstastny-cz opened a new issue, #776:
URL: https://github.com/apache/incubator-kie-issues/issues/776

   There are several places in pipelines where some changes are needed to be 
pushed to a protected branch (main in incubator-kie-benchmarks, 
incubator-kie-optaplanner,..).
   * prepare-for-release and setup-branch pipelines and jobs invoked by them
   
   There are 2 restrictions:
   * can't push into main
   * a PR needs at least 1 approval by code-owner=committer (and not the author 
of the PR)
   
   To overcome, there need to be 2 github tokens involved and gh cli used 
instead of hub cli, so depends on:
   * #768 
   
   And then the course of action can be:
   ```
   sh "git checkout -b ${getPRBranch()}"
   sh 'git diff'
   String commitMsg="Add release branch ${getEcosystemReleaseBranch()} after 
cut-off"
   
githubscm.setUserConfigFromCreds(env.SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID)
   githubscm.commitChanges(commitMsg)
   githubscm.pushObject('origin', getPRBranch(), 
env.SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID)
   // Create PR
   def prBody = "Generated by ${BUILD_URL}"
   
   String prLink = githubscm.createPR(commitMsg, prBody, 
env.SEED_CONFIG_FILE_GIT_BRANCH, env.SEED_CONFIG_FILE_GIT_AUTHOR_CREDS_ID)
   githubscm.approvePR(prLink, env.SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID)
   githubscm.mergePR(prLink, env.SEED_CONFIG_FILE_GIT_AUTHOR_PUSH_CREDS_ID)
   sendNotification("Main config has been updated with release branch 
${getEcosystemReleaseBranch()}")
   ```
   
   Important to note - token used for createPR is not the committer (so one 
without push privileges) to save the committer for consecutive PR approval.
   
   getPRBranch() is a randomized branch name, using env variable from:
   ```
       environment {
           PR_BRANCH_HASH = "${util.generateHash(10)}"
       }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to