diff --git a/dist/index.js b/dist/index.js index 8c9fc9c..a317d4e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1804,22 +1804,30 @@ const TARGET_FILE = core.getInput("TARGET_FILE"); const capitalize = (str) => str.slice(0, 1).toUpperCase() + str.slice(1); -const urlPrefix = "https://github.com"; - /** * Returns a URL in markdown format for PR's and issues * @param {Object | String} item - holds information concerning the issue/PR * * @returns {String} */ - const toUrlFormat = (item) => { - if (typeof item === "object") { - return Object.hasOwnProperty.call(item.payload, "issue") - ? `[#${item.payload.issue.number}](${urlPrefix}/${item.repo.name}/issues/${item.payload.issue.number})` - : `[#${item.payload.pull_request.number}](${urlPrefix}/${item.repo.name}/pull/${item.payload.pull_request.number})`; + if (typeof item !== "object") { + return `[${item}](https://github.com/${item})`; + } + if (Object.hasOwnProperty.call(item.payload, "comment")) { + return `[#${item.payload.issue.number}](${item.payload.comment.html_url})`; + } + if (Object.hasOwnProperty.call(item.payload, "issue")) { + return `[#${item.payload.issue.number}](${item.payload.issue.html_url})`; + } + if (Object.hasOwnProperty.call(item.payload, "pull_request")) { + return `[#${item.payload.pull_request.number}](${item.payload.pull_request.html_url})`; + } + + if (Object.hasOwnProperty.call(item.payload, "release")) { + const release = item.payload.release.name || item.payload.release.tag_name; + return `[${release}](${item.payload.release.html_url})`; } - return `[${item}](${urlPrefix}/${item})`; }; /** @@ -1883,9 +1891,7 @@ const serializers = { }, ReleaseEvent: (item) => { return `🚀 ${capitalize(item.payload.action)} release ${toUrlFormat( - item.payload.release.name - ? item.payload.release.name - : item.payload.release.tag_name + item )} in ${toUrlFormat(item.repo.name)}`; }, }; diff --git a/index.js b/index.js index 6b63690..8b23245 100644 --- a/index.js +++ b/index.js @@ -21,22 +21,30 @@ const TARGET_FILE = core.getInput("TARGET_FILE"); const capitalize = (str) => str.slice(0, 1).toUpperCase() + str.slice(1); -const urlPrefix = "https://github.com"; - /** * Returns a URL in markdown format for PR's and issues * @param {Object | String} item - holds information concerning the issue/PR * * @returns {String} */ - const toUrlFormat = (item) => { - if (typeof item === "object") { - return Object.hasOwnProperty.call(item.payload, "issue") - ? `[#${item.payload.issue.number}](${urlPrefix}/${item.repo.name}/issues/${item.payload.issue.number})` - : `[#${item.payload.pull_request.number}](${urlPrefix}/${item.repo.name}/pull/${item.payload.pull_request.number})`; + if (typeof item !== "object") { + return `[${item}](https://github.com/${item})`; + } + if (Object.hasOwnProperty.call(item.payload, "comment")) { + return `[#${item.payload.issue.number}](${item.payload.comment.html_url})`; + } + if (Object.hasOwnProperty.call(item.payload, "issue")) { + return `[#${item.payload.issue.number}](${item.payload.issue.html_url})`; + } + if (Object.hasOwnProperty.call(item.payload, "pull_request")) { + return `[#${item.payload.pull_request.number}](${item.payload.pull_request.html_url})`; + } + + if (Object.hasOwnProperty.call(item.payload, "release")) { + const release = item.payload.release.name || item.payload.release.tag_name; + return `[${release}](${item.payload.release.html_url})`; } - return `[${item}](${urlPrefix}/${item})`; }; /** @@ -100,9 +108,7 @@ const serializers = { }, ReleaseEvent: (item) => { return `🚀 ${capitalize(item.payload.action)} release ${toUrlFormat( - item.payload.release.name - ? item.payload.release.name - : item.payload.release.tag_name + item )} in ${toUrlFormat(item.repo.name)}`; }, }; diff --git a/package-lock.json b/package-lock.json index c1e3038..36a4688 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "github-activity-readme", - "version": "0.4.0", + "version": "0.4.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "github-activity-readme", - "version": "0.4.0", + "version": "0.4.1", "license": "MIT", "dependencies": { "@actions/core": "^1.2.6", diff --git a/package.json b/package.json index 2c05738..b5d8dcd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "github-activity-readme", - "version": "0.4.0", + "version": "0.4.1", "description": "Updates README with the recent GitHub activity of a user", "main": "index.js", "keywords": [],