From 5ee83752fd1b9430c6459dfd5993d347f6e2a5e5 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Fri, 18 Sep 2020 18:24:57 +0000 Subject: [PATCH] build(release): compiled action for 1.3.0 [skip ci] --- dist/index.js | 68 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 51 insertions(+), 17 deletions(-) diff --git a/dist/index.js b/dist/index.js index 59c42aa2..bb4950d5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -477,6 +477,8 @@ async function main() { return; } + const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/"); + try { const inputs = { title: core.getInput("title"), @@ -484,17 +486,20 @@ async function main() { branch: core.getInput("branch").replace(/^refs\/heads\//, ""), path: core.getInput("path"), commitMessage: core.getInput("commit-message"), - author: core.getInput("author") + author: core.getInput("author"), + labels: core.getInput("labels"), }; core.debug(`Inputs: ${inspect(inputs)}`); const { - data: { default_branch } - } = await request(`GET /repos/${process.env.GITHUB_REPOSITORY}`, { + data: { default_branch }, + } = await request(`GET /repos/{owner}/{repo}`, { headers: { - authorization: `token ${process.env.GITHUB_TOKEN}` - } + authorization: `token ${process.env.GITHUB_TOKEN}`, + }, + owner, + repo, }); const DEFAULT_BRANCH = default_branch; core.debug(`DEFAULT_BRANCH: ${DEFAULT_BRANCH}`); @@ -527,7 +532,7 @@ async function main() { await setGitUser({ name, - email + email, }); } @@ -569,7 +574,7 @@ async function main() { if (remoteBranchExists) { const q = `head:${inputs.branch} type:pr is:open repo:${process.env.GITHUB_REPOSITORY}`; const { data } = await request("GET /search/issues", { - q + q, }); if (data.total_count > 0) { @@ -582,21 +587,43 @@ async function main() { core.debug(`Creating pull request`); const { - data: { html_url } - } = await request(`POST /repos/${process.env.GITHUB_REPOSITORY}/pulls`, { + data: { html_url, number }, + } = await request(`POST /repos/{owner}/{repo}/pulls`, { headers: { - authorization: `token ${process.env.GITHUB_TOKEN}` + authorization: `token ${process.env.GITHUB_TOKEN}`, }, + owner, + repo, title: inputs.title, body: inputs.body, head: inputs.branch, - base: DEFAULT_BRANCH + base: DEFAULT_BRANCH, }); - core.info(`Pull request created: ${html_url}`); + core.info(`Pull request created: ${html_url} (#${number})`); + + if (inputs.labels) { + core.debug(`Adding labels: ${inputs.labels}`); + const labels = inputs.labels.trim().split(/\s*,\s*/); + const { data } = await request( + `POST /repos/{owner}/{repo}/issues/{issue_number}/labels`, + { + headers: { + authorization: `token ${process.env.GITHUB_TOKEN}`, + }, + owner, + repo, + issue_number: number, + labels, + } + ); + core.info(`Labels added: ${labels.join(", ")}`); + core.debug(inspect(data)); + } + await runShellCommand(`git stash pop || true`); } catch (error) { - core.debug(inspect(error)); + core.info(inspect(error)); core.setFailed(error.message); } } @@ -614,7 +641,7 @@ async function getLocalChanges(path) { return { hasUncommitedChanges, - hasChanges: hasUncommitedChanges + hasChanges: hasUncommitedChanges, }; } @@ -625,7 +652,7 @@ async function getGitUser() { return { name, - email + email, }; } catch (error) { return; @@ -3876,6 +3903,12 @@ function convertBody(buffer, headers) { // html4 if (!res && str) { res = /