From f2a0a5b2916d8a2be77e82215d777dd304197000 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 22 Apr 2022 22:40:58 +0300 Subject: [PATCH] text payload --- res.js | 194 +++++++++++++++++++++++++++++++++++++++++ src/develop_actions.js | 7 +- 2 files changed, 198 insertions(+), 3 deletions(-) diff --git a/res.js b/res.js index e69de29..81268c3 100644 --- a/res.js +++ b/res.js @@ -0,0 +1,194 @@ +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", + }, +}; diff --git a/src/develop_actions.js b/src/develop_actions.js index f75b47a..be3086a 100644 --- a/src/develop_actions.js +++ b/src/develop_actions.js @@ -16,12 +16,13 @@ const run = async () => { .slice(1) .join("/"); + // context + console.log(context.payload); 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); - console.log("commits", context.payload?.commits); let commits = ""; context.payload?.commits?.forEach((e, i) => { @@ -32,10 +33,10 @@ const run = async () => { !e.message.includes("Skip") ) commits = - commits + i !== 0 ? "> " + e.message : "\n\n" + "> " + e.message; + i === 0 ? "> " + e.message : commits + "\n\n" + "> " + e.message; }); - console.log("formatted commits", commits); + console.log(commits); const createpr = await octokit.request( `POST /repos/${context.payload?.full_name}/pulls`,