Skip to content

Commit

Permalink
Chore: post a comment if cherry pick failed [skip-ci] (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZheSun88 authored Feb 11, 2021
1 parent b734bbf commit ec40bc9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion scripts/cherryPick.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ let arrTitle = [];
let arrURL = [];
let arrSHA = [];
let arrBranch = [];
let arrUser = [];

const repo = "vaadin/vaadin-flow-components";
const token = process.env['GITHUB_TOKEN'];
Expand Down Expand Up @@ -73,12 +74,13 @@ function filterCommits(commits){
commit.labels.forEach(label => {
let branch = /target\/(.*)/.exec(label.name);
if (branch){
console.log(commit.number, commit.url, commit.merge_commit_sha, branch[1]);
console.log(commit.number, commit.user.login, commit.url, commit.merge_commit_sha, branch[1]);
arrPR.push(commit.number);
arrSHA.push(commit.merge_commit_sha);
arrURL.push(commit.url);
arrBranch.push(branch[1]);
arrTitle.push(`${commit.title} (#${commit.number}) (CP: ${branch[1]})`);
arrUser.push(`@${commit.user.login}`);
}
})
}
Expand Down Expand Up @@ -108,6 +110,7 @@ async function cherryPickCommits(){
await exec(`git checkout master`);
await exec(`git branch -D ${branchName}`);
await labelCommit(arrURL[i], `need to pick manually`);
await postComment(arrURL[i], arrUser[i], arrBranch[i]);
console.error(`Cannot Pick the Commit:${arrSHA[i]}, error :${err}`);
continue;
}
Expand All @@ -132,6 +135,18 @@ async function labelCommit(url, label){
await axios.post(issueURL, {"labels":[label]}, options);
}

async function postComment(url, userName, branch){
let issueURL = url.replace("pulls", "issues") + "/comments";
const options = {
headers:{
'User-Agent': 'Vaadin Cherry Pick',
'Authorization': `token ${token}`,
}
};

await axios.post(issueURL, {"body":`Hi ${userName} , this commit cannot be picked to ${branch} by this bot, can you take a look and pick it manually?`}, options);
}

async function createPR(title, head, base){
const payload = {title, head, base};

Expand Down

0 comments on commit ec40bc9

Please sign in to comment.