Skip to content

Commit

Permalink
build(release): compiled action for 1.3.0
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
semantic-release-bot committed Sep 18, 2020
1 parent d6a6f40 commit 5ee8375
Showing 1 changed file with 51 additions and 17 deletions.
68 changes: 51 additions & 17 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,24 +477,29 @@ async function main() {
return;
}

const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");

try {
const inputs = {
title: core.getInput("title"),
body: core.getInput("body"),
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}`);
Expand Down Expand Up @@ -527,7 +532,7 @@ async function main() {

await setGitUser({
name,
email
email,
});
}

Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
}
Expand All @@ -614,7 +641,7 @@ async function getLocalChanges(path) {

return {
hasUncommitedChanges,
hasChanges: hasUncommitedChanges
hasChanges: hasUncommitedChanges,
};
}

Expand All @@ -625,7 +652,7 @@ async function getGitUser() {

return {
name,
email
email,
};
} catch (error) {
return;
Expand Down Expand Up @@ -3876,6 +3903,12 @@ function convertBody(buffer, headers) {
// html4
if (!res && str) {
res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str);
if (!res) {
res = /<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(str);
if (res) {
res.pop(); // drop last quote
}
}

if (res) {
res = /charset=(.*)/i.exec(res.pop());
Expand Down Expand Up @@ -4883,7 +4916,7 @@ function fetch(url, opts) {
// HTTP fetch step 5.5
switch (request.redirect) {
case 'error':
reject(new FetchError(`redirect mode is set to error: ${request.url}`, 'no-redirect'));
reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect'));
finalize();
return;
case 'manual':
Expand Down Expand Up @@ -4922,7 +4955,8 @@ function fetch(url, opts) {
method: request.method,
body: request.body,
signal: request.signal,
timeout: request.timeout
timeout: request.timeout,
size: request.size
};

// HTTP-redirect fetch step 9
Expand Down

0 comments on commit 5ee8375

Please sign in to comment.