Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
194 changes: 0 additions & 194 deletions res.js
Original file line number Diff line number Diff line change
@@ -1,194 +0,0 @@
exports.response = {
after: "94a28b830c5af1d1a5e0a1ccd55ac9f9df8244da",
base_ref: null,
before: "cc8b67c069125765f31ee6908392e0439f0d04eb",
commits: [
{
author: [Object],
committer: [Object],
distinct: false,
id: "49f9be33fb8cbf34c5a891db989e3de07c27b7a1",
message: "test commit",
timestamp: "2022-04-22T20:00:25+03:00",
tree_id: "969c2c9cb3ca68847fcf744a21df3672c153127d",
url: "https://github.com/bmsteven/demo/commit/49f9be33fb8cbf34c5a891db989e3de07c27b7a1",
},
{
author: [Object],
committer: [Object],
distinct: true,
id: "94a28b830c5af1d1a5e0a1ccd55ac9f9df8244da",
message:
"Merge pull request #22 from bmsteven/test_branch\n\ntest commit",
timestamp: "2022-04-22T20:01:07+03:00",
tree_id: "969c2c9cb3ca68847fcf744a21df3672c153127d",
url: "https://github.com/bmsteven/demo/commit/94a28b830c5af1d1a5e0a1ccd55ac9f9df8244da",
},
],
compare:
"https://github.com/bmsteven/demo/compare/cc8b67c06912...94a28b830c5a",
created: false,
deleted: false,
forced: false,
head_commit: {
author: {
email: "48621248+bmsteven@users.noreply.github.com",
name: "Benedict Steven",
username: "bmsteven",
},
committer: {
email: "noreply@github.com",
name: "GitHub",
username: "web-flow",
},
distinct: true,
id: "94a28b830c5af1d1a5e0a1ccd55ac9f9df8244da",
message: "Merge pull request #22 from bmsteven/test_branch\n\ntest commit",
timestamp: "2022-04-22T20:01:07+03:00",
tree_id: "969c2c9cb3ca68847fcf744a21df3672c153127d",
url: "https://github.com/bmsteven/demo/commit/94a28b830c5af1d1a5e0a1ccd55ac9f9df8244da",
},
pusher: {
email: "48621248+bmsteven@users.noreply.github.com",
name: "bmsteven",
},
ref: "refs/heads/develop",
repository: {
allow_forking: true,
archive_url:
"https://api.github.com/repos/bmsteven/demo/{archive_format}{/ref}",
archived: false,
assignees_url:
"https://api.github.com/repos/bmsteven/demo/assignees{/user}",
blobs_url: "https://api.github.com/repos/bmsteven/demo/git/blobs{/sha}",
branches_url:
"https://api.github.com/repos/bmsteven/demo/branches{/branch}",
clone_url: "https://github.com/bmsteven/demo.git",
collaborators_url:
"https://api.github.com/repos/bmsteven/demo/collaborators{/collaborator}",
comments_url:
"https://api.github.com/repos/bmsteven/demo/comments{/number}",
commits_url: "https://api.github.com/repos/bmsteven/demo/commits{/sha}",
compare_url:
"https://api.github.com/repos/bmsteven/demo/compare/{base}...{head}",
contents_url: "https://api.github.com/repos/bmsteven/demo/contents/{+path}",
contributors_url: "https://api.github.com/repos/bmsteven/demo/contributors",
created_at: 1553584187,
default_branch: "master",
deployments_url: "https://api.github.com/repos/bmsteven/demo/deployments",
description: "demo repository",
disabled: false,
downloads_url: "https://api.github.com/repos/bmsteven/demo/downloads",
events_url: "https://api.github.com/repos/bmsteven/demo/events",
fork: false,
forks: 0,
forks_count: 0,
forks_url: "https://api.github.com/repos/bmsteven/demo/forks",
full_name: "bmsteven/demo",
git_commits_url:
"https://api.github.com/repos/bmsteven/demo/git/commits{/sha}",
git_refs_url: "https://api.github.com/repos/bmsteven/demo/git/refs{/sha}",
git_tags_url: "https://api.github.com/repos/bmsteven/demo/git/tags{/sha}",
git_url: "git://github.com/bmsteven/demo.git",
has_downloads: true,
has_issues: true,
has_pages: false,
has_projects: true,
has_wiki: true,
homepage: null,
hooks_url: "https://api.github.com/repos/bmsteven/demo/hooks",
html_url: "https://github.com/bmsteven/demo",
id: 177733530,
is_template: false,
issue_comment_url:
"https://api.github.com/repos/bmsteven/demo/issues/comments{/number}",
issue_events_url:
"https://api.github.com/repos/bmsteven/demo/issues/events{/number}",
issues_url: "https://api.github.com/repos/bmsteven/demo/issues{/number}",
keys_url: "https://api.github.com/repos/bmsteven/demo/keys{/key_id}",
labels_url: "https://api.github.com/repos/bmsteven/demo/labels{/name}",
language: "JavaScript",
languages_url: "https://api.github.com/repos/bmsteven/demo/languages",
license: null,
master_branch: "master",
merges_url: "https://api.github.com/repos/bmsteven/demo/merges",
milestones_url:
"https://api.github.com/repos/bmsteven/demo/milestones{/number}",
mirror_url: null,
name: "demo",
node_id: "MDEwOlJlcG9zaXRvcnkxNzc3MzM1MzA=",
notifications_url:
"https://api.github.com/repos/bmsteven/demo/notifications{?since,all,participating}",
open_issues: 0,
open_issues_count: 0,
owner: {
avatar_url: "https://avatars.githubusercontent.com/u/48621248?v=4",
email: "48621248+bmsteven@users.noreply.github.com",
events_url: "https://api.github.com/users/bmsteven/events{/privacy}",
followers_url: "https://api.github.com/users/bmsteven/followers",
following_url:
"https://api.github.com/users/bmsteven/following{/other_user}",
gists_url: "https://api.github.com/users/bmsteven/gists{/gist_id}",
gravatar_id: "",
html_url: "https://github.com/bmsteven",
id: 48621248,
login: "bmsteven",
name: "bmsteven",
node_id: "MDQ6VXNlcjQ4NjIxMjQ4",
organizations_url: "https://api.github.com/users/bmsteven/orgs",
received_events_url:
"https://api.github.com/users/bmsteven/received_events",
repos_url: "https://api.github.com/users/bmsteven/repos",
site_admin: false,
starred_url:
"https://api.github.com/users/bmsteven/starred{/owner}{/repo}",
subscriptions_url: "https://api.github.com/users/bmsteven/subscriptions",
type: "User",
url: "https://api.github.com/users/bmsteven",
},
private: false,
pulls_url: "https://api.github.com/repos/bmsteven/demo/pulls{/number}",
pushed_at: 1650646867,
releases_url: "https://api.github.com/repos/bmsteven/demo/releases{/id}",
size: 169,
ssh_url: "git@github.com:bmsteven/demo.git",
stargazers: 0,
stargazers_count: 0,
stargazers_url: "https://api.github.com/repos/bmsteven/demo/stargazers",
statuses_url: "https://api.github.com/repos/bmsteven/demo/statuses/{sha}",
subscribers_url: "https://api.github.com/repos/bmsteven/demo/subscribers",
subscription_url: "https://api.github.com/repos/bmsteven/demo/subscription",
svn_url: "https://github.com/bmsteven/demo",
tags_url: "https://api.github.com/repos/bmsteven/demo/tags",
teams_url: "https://api.github.com/repos/bmsteven/demo/teams",
topics: [],
trees_url: "https://api.github.com/repos/bmsteven/demo/git/trees{/sha}",
updated_at: "2022-04-20T22:35:19Z",
url: "https://github.com/bmsteven/demo",
visibility: "public",
watchers: 0,
watchers_count: 0,
},
sender: {
avatar_url: "https://avatars.githubusercontent.com/u/48621248?v=4",
events_url: "https://api.github.com/users/bmsteven/events{/privacy}",
followers_url: "https://api.github.com/users/bmsteven/followers",
following_url:
"https://api.github.com/users/bmsteven/following{/other_user}",
gists_url: "https://api.github.com/users/bmsteven/gists{/gist_id}",
gravatar_id: "",
html_url: "https://github.com/bmsteven",
id: 48621248,
login: "bmsteven",
node_id: "MDQ6VXNlcjQ4NjIxMjQ4",
organizations_url: "https://api.github.com/users/bmsteven/orgs",
received_events_url:
"https://api.github.com/users/bmsteven/received_events",
repos_url: "https://api.github.com/users/bmsteven/repos",
site_admin: false,
starred_url: "https://api.github.com/users/bmsteven/starred{/owner}{/repo}",
subscriptions_url: "https://api.github.com/users/bmsteven/subscriptions",
type: "User",
url: "https://api.github.com/users/bmsteven",
},
};
45 changes: 33 additions & 12 deletions src/develop_actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,46 @@ const octokit = github.getOctokit(GITHUB_TOKEN);
const { context = {} } = github;

const run = async () => {
// console.log(context.payload);
// console.log(GITHUB_TOKEN);
// console.log("test actions");
try {
const branch_name = context.payload?.head_commit?.message
?.split("from")[1]
.split("\n")[0]
?.split("/")[1];
?.split("/")
.slice(1)
.join("/");

console.log(branch_name);
console.log("branch name", branch_name);
console.log("full name", context.payload?.full_name);
console.log("owner", context.payload?.owner?.login);
console.log("repo", context.payload?.repository?.name);

const createpr = await octokit.request("POST /repos/bmsteven/demo/pulls", {
owner: "bmsteven",
repo: "demo",
title: "Amazing new feature",
body: "Please pull these awesome changes in!",
head: branch_name,
base: "staging",
console.log("commits", context.payload?.commits);
let commits = "";

context.payload?.commits?.forEach((e, i) => {
if (
!e.message.includes("Merge") &&
!e.message.includes("Merged") &&
!e.message.includes("skip") &&
!e.message.includes("Skip")
)
commits =
commits + i !== 0 ? "> " + e.message : "\n\n" + "> " + e.message;
});

console.log("formatted commits", commits);

const createpr = await octokit.request(
`POST /repos/${context.payload?.full_name}/pulls`,
{
owner: context.payload?.owner?.login,
repo: context.payload?.repository?.name,
title: branch_name,
body: commits,
head: branch_name,
base: "staging",
}
);
console.log("createPr", createpr?.data);
} catch (error) {
console.log("error", error?.message);
Expand Down