From c225cc18f4d4d18a5d85d8e95085d59dd6bf376d Mon Sep 17 00:00:00 2001 From: gkr-bot Date: Tue, 30 Nov 2021 18:04:22 +0000 Subject: [PATCH] [skip-ci] Published 1.6.5 --- dist/blog-post-workflow.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/blog-post-workflow.js b/dist/blog-post-workflow.js index 6e8b3d9..cd0d054 100644 --- a/dist/blog-post-workflow.js +++ b/dist/blog-post-workflow.js @@ -135,5 +135,5 @@ function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Obje },{"@actions/core":"FTVr"}],"KSDV":[function(require,module,exports) { const{updateAndParseCompoundParams:e}=require("./utils"),t=require("@actions/core"),o={stackoverflow:"Comment by $author",stackexchange:"Comment by $author"},a=t.getInput("filter_comments").trim().split(",").map(t=>(t=t.trim()).startsWith("stackoverflow")||t.startsWith("stackexchange")?e(t,o):t),i=e=>!(-1!==a.indexOf("medium")&&e.link&&e.link.includes("medium.com")&&void 0===e.categories),r=e=>!(-1!==a.indexOf("stackoverflow")&&e.link&&e.link.includes("stackoverflow.com")&&e.title.startsWith(o.stackoverflow.replace(/\$author/g,e.author))),s=e=>!(-1!==a.indexOf("stackexchange")&&e.link&&e.link.includes("stackexchange.com")&&e.title.startsWith(o.stackexchange.replace(/\$author/g,e.author)));module.exports={ignoreMediumComments:i,ignoreStackOverflowComments:r,ignoreStackExchangeComments:s}; },{"./utils":"FOZT","@actions/core":"FTVr"}],"MHPq":[function(require,module,exports) { -function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)}return r}function _objectSpread(e){for(var t=1;te.trim()),GITHUB_TOKEN=core.getInput("gh_token"),CUSTOM_TAGS={},ENABLE_KEEPALIVE="true"===core.getInput("enable_keepalive"),retryConfig={retries:Number.parseInt(core.getInput("retry_count")),factor:1,minTimeout:1e3*Number.parseInt(core.getInput("retry_wait_time"))};core.setSecret(GITHUB_TOKEN),core.getInput("custom_tags").trim().split(",").forEach(e=>{e=e.trim(),updateAndParseCompoundParams(e,CUSTOM_TAGS)});const promiseArray=[],runnerNameArray=[];let postsArray=[],jobFailFlag=!1;const feedObjString=core.getInput("feed_list").trim();let feedList=feedObjString.split(",").map(e=>e.trim());0===feedList.length&&(core.error("Please double check the value of feed_list"),process.exit(1));const feedNames=core.getInput("feed_names").trim(),feedNamesList=feedNames.split(",").map(e=>e.trim()),customTagArgs=Object.keys(CUSTOM_TAGS).map(e=>[CUSTOM_TAGS[e],e]);let parser=new Parser({headers:{"User-Agent":userAgent,Accept:acceptHeader},customFields:{item:[...customTagArgs]}});feedList.forEach(siteUrl=>{runnerNameArray.push(siteUrl),promiseArray.push(new Promise((resolve,reject)=>{promiseRetry((e,t)=>(t>1&&core.info(`Previous try for ${siteUrl} failed, retrying: ${t-1}`),parser.parseURL(siteUrl).catch(e)),retryConfig).then(data=>{if(data.items){const responsePosts=data.items,posts=responsePosts.filter(ignoreMediumComments).filter(ignoreStackOverflowComments).filter(ignoreStackExchangeComments).map(item=>{ENABLE_SORT&&!item.pubDate&&reject("Cannot read response->item->pubDate"),item.title||reject("Cannot read response->item->title"),item.link||reject("Cannot read response->item->link");let customTags={};Object.keys(CUSTOM_TAGS).forEach(e=>{item[e]&&Object.assign(customTags,{[e]:item[e]})});const categories=item.categories?item.categories:[];let post=_objectSpread(_objectSpread({title:item.title.trim(),url:item.link.trim(),description:item.content?item.content:""},customTags),{},{categories:categories});if(ENABLE_SORT&&(post.date=new Date(item.pubDate.trim())),TITLE_MAX_LENGTH&&post&&post.title&&(post.title=truncateString(post.title,TITLE_MAX_LENGTH)),DESCRIPTION_MAX_LENGTH&&post&&post.description){const e=post.description.trim();post.description=truncateString(e,DESCRIPTION_MAX_LENGTH)}const disableHtmlEncoding="false"!==core.getInput("disable_html_encoding");if(disableHtmlEncoding||Object.keys(post).forEach(e=>{"string"==typeof post[e]&&"url"!==e&&(post[e]=escapeHTML(post[e]))}),ITEM_EXEC)try{eval(ITEM_EXEC)}catch(e){core.error("Failure in executing `item_exec` parameter"),core.error(e),process.exit(1)}return post});resolve(posts)}else reject("Cannot read response->item")},e=>{reject(e)})}))}),Promise.allSettled(promiseArray).then(e=>{e.forEach((e,t)=>{"fulfilled"===e.status?(core.info(runnerNameArray[t]+" runner succeeded. Post count: "+e.value.length),void 0!==typeof feedNamesList[t]&&feedNamesList[t]&&(e.value=e.value.map(e=>(e.feedName=feedNamesList[t],e))),postsArray.push(...e.value)):(jobFailFlag=!0,core.error(runnerNameArray[t]+" runner failed, please verify the configuration. Error:"),core.error(e.reason))})}).finally(async()=>{if(postsArray=postsArray.filter(e=>null!==e),ENABLE_SORT&&postsArray.sort(function(e,t){return t.date-e.date}),(postsArray=postsArray.slice(0,TOTAL_POST_COUNT)).length>0)try{process.env.TEST_MODE||(await exec("git",["config","pull.rebase","true"],{stdio:["pipe","pipe","pipe"]}),await exec("git",["pull"],{stdio:["pipe","pipe","pipe"]}));const t=core.getInput("template"),r=getParameterisedTemplate(t,"randomEmoji"),o=getParameterisedTemplate(t,"emojiKey"),s=postsArray.reduce((e,s,a)=>{if("default"===t)return e+`\n- [${s.title}](${s.url})`+(a+1===postsArray.length?"\n":"");{const i=core.getInput("categories_template"),n="default"===i?s.categories.join(", "):s.categories.reduce((e,t)=>e+i.replace(/\$category\b/g,t.toString()),""),c=dateFormat(s.date,core.getInput("date_format"));let p=t.replace(/\$title\b/g,s.title).replace(/\$url\b/g,s.url).replace(/\$description\b/g,s.description).replace(/\$date\b/g,c).replace(/\$counter\b/g,(a+1).toString()).replace(/\$feedName\b/g,s.feedName?s.feedName:"").replace(/\$categories\b/g,n.toString()).replace(/\$newline/g,"\n");if(Object.keys(CUSTOM_TAGS).forEach(e=>{const t=s[e]?s[e]:"";p=p.replace(new RegExp("\\$"+e+"\\b","g"),t)}),r){const e=(process.env.GITHUB_REPOSITORY&&!process.env.TEST_MODE?process.env.GITHUB_REPOSITORY:"example")+a,t=r[rand.create(e).range(r.length)];p=p.replace(/\$randomEmoji\((\S)*\)/g,t)}return o&&(p=p.replace(/\$emojiKey\((\S)*\)/g,o[a%o.length])),e+p}},"");"false"!==core.getInput("output_only")&&(core.info("outputOnly mode: set `results` variable. Readme not committed."),core.setOutput("results",postsArray),process.exit(jobFailFlag?1:0));let a=0;if(README_FILE_PATH_LIST.forEach(e=>{const t=fs.readFileSync(e,"utf8"),r=buildReadme(t,s);r!==t&&(core.info("Writing to "+e),fs.writeFileSync(e,r),a+=1)}),a>0)process.env.TEST_MODE||await commitReadme(GITHUB_TOKEN,README_FILE_PATH_LIST).then(()=>{process.exit(jobFailFlag?1:0)});else{if(!process.env.TEST_MODE&&ENABLE_KEEPALIVE){const e=core.getInput("committer_username"),t=core.getInput("committer_email"),r=await keepaliveWorkflow.KeepAliveWorkflow(GITHUB_TOKEN,e,t,"dummy commit to keep the repository active, see https://git.io/Jtm4V",50);core.info(r)}else core.info("No change detected, skipping");process.exit(jobFailFlag?1:0)}}catch(e){core.error(e),process.exit(1)}else core.info("0 blog posts fetched"),process.exit(jobFailFlag?1:0)}); +function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,o)}return r}function _objectSpread(e){for(var t=1;te.trim()),GITHUB_TOKEN=core.getInput("gh_token"),CUSTOM_TAGS={},ENABLE_KEEPALIVE="true"===core.getInput("enable_keepalive"),retryConfig={retries:Number.parseInt(core.getInput("retry_count")),factor:1,minTimeout:1e3*Number.parseInt(core.getInput("retry_wait_time"))};core.setSecret(GITHUB_TOKEN),core.getInput("custom_tags").trim().split(",").forEach(e=>{e=e.trim(),updateAndParseCompoundParams(e,CUSTOM_TAGS)});const promiseArray=[],runnerNameArray=[];let postsArray=[],jobFailFlag=!1;const feedObjString=core.getInput("feed_list").trim();let feedList=feedObjString.split(",").map(e=>e.trim());0===feedList.length&&(core.error("Please double check the value of feed_list"),process.exit(1));const feedNames=core.getInput("feed_names").trim(),feedNamesList=feedNames.split(",").map(e=>e.trim()),customTagArgs=Object.keys(CUSTOM_TAGS).map(e=>[CUSTOM_TAGS[e],e]);let parser=new Parser({headers:{"User-Agent":userAgent,Accept:acceptHeader},customFields:{item:[...customTagArgs]}});feedList.forEach(siteUrl=>{runnerNameArray.push(siteUrl),promiseArray.push(new Promise((resolve,reject)=>{promiseRetry((e,t)=>(t>1&&core.info(`Previous try for ${siteUrl} failed, retrying: ${t-1}`),parser.parseURL(siteUrl).catch(e)),retryConfig).then(data=>{if(data.items){const responsePosts=data.items,posts=responsePosts.filter(ignoreMediumComments).filter(ignoreStackOverflowComments).filter(ignoreStackExchangeComments).map(item=>{ENABLE_SORT&&!item.pubDate&&reject("Cannot read response->item->pubDate"),item.title||reject("Cannot read response->item->title"),item.link||reject("Cannot read response->item->link");let customTags={};Object.keys(CUSTOM_TAGS).forEach(e=>{item[e]&&Object.assign(customTags,{[e]:item[e]})});const categories=item.categories?item.categories:[];let post=_objectSpread(_objectSpread({title:item.title.trim(),url:item.link.trim(),description:item.content?item.content:""},customTags),{},{categories:categories});if(ENABLE_SORT&&(post.date=new Date(item.pubDate.trim())),TITLE_MAX_LENGTH&&post&&post.title&&(post.title=truncateString(post.title,TITLE_MAX_LENGTH)),DESCRIPTION_MAX_LENGTH&&post&&post.description){const e=post.description.trim();post.description=truncateString(e,DESCRIPTION_MAX_LENGTH)}const disableHtmlEncoding="false"!==core.getInput("disable_html_encoding");if(disableHtmlEncoding||Object.keys(post).forEach(e=>{"string"==typeof post[e]&&"url"!==e&&(post[e]=escapeHTML(post[e]))}),ITEM_EXEC)try{eval(ITEM_EXEC)}catch(e){core.error("Failure in executing `item_exec` parameter"),core.error(e),process.exit(1)}return post});resolve(posts)}else reject("Cannot read response->item")},e=>{reject(e)})}))}),Promise.allSettled(promiseArray).then(e=>{e.forEach((e,t)=>{"fulfilled"===e.status?(core.info(runnerNameArray[t]+" runner succeeded. Post count: "+e.value.length),void 0!==typeof feedNamesList[t]&&feedNamesList[t]&&(e.value=e.value.map(e=>(e.feedName=feedNamesList[t],e))),postsArray.push(...e.value)):(jobFailFlag=!0,core.error(runnerNameArray[t]+" runner failed, please verify the configuration. Error:"),core.error(e.reason))})}).finally(async()=>{if(postsArray=postsArray.filter(e=>null!==e),ENABLE_SORT&&postsArray.sort(function(e,t){return t.date-e.date}),(postsArray=postsArray.slice(0,TOTAL_POST_COUNT)).length>0)try{process.env.TEST_MODE||(await exec("git",["config","pull.rebase","true"],{stdio:["pipe","pipe","pipe"]}),await exec("git",["pull"],{stdio:["pipe","pipe","pipe"]}));const t=core.getInput("template"),r=getParameterisedTemplate(t,"randomEmoji"),o=getParameterisedTemplate(t,"emojiKey"),s=postsArray.reduce((e,s,i)=>{if("default"===t)return e+`\n- [${s.title}](${s.url})`+(i+1===postsArray.length?"\n":"");{const a=core.getInput("categories_template"),n="default"===a?s.categories.join(", "):s.categories.reduce((e,t)=>e+a.replace(/\$category\b/g,t.toString()),""),c=dateFormat(s.date,core.getInput("date_format"));let p=t.replace(/\$title\b/g,s.title).replace(/\$url\b/g,s.url).replace(/\$description\b/g,s.description).replace(/\$date\b/g,c).replace(/\$counter\b/g,(i+1).toString()).replace(/\$feedName\b/g,s.feedName?s.feedName:"").replace(/\$categories\b/g,n.toString()).replace(/\$newline/g,"\n");if(Object.keys(CUSTOM_TAGS).forEach(e=>{const t=s[e]?s[e]:"";p=p.replace(new RegExp("\\$"+e+"\\b","g"),t)}),r){const e=(process.env.GITHUB_REPOSITORY&&!process.env.TEST_MODE?process.env.GITHUB_REPOSITORY:"example")+i,t=r[rand.create(e).range(r.length)];p=p.replace(/\$randomEmoji\((\S)*\)/g,t)}return o&&(p=p.replace(/\$emojiKey\((\S)*\)/g,o[i%o.length])),e+p}},"");if("false"!==core.getInput("output_only")){core.info("outputOnly mode: set `results` variable. Readme not committed."),core.setOutput("results",postsArray);const e=path.join("/","tmp","blog_post_workflow_output.json");fs.existsSync(e)&&fs.rmSync(e),fs.writeFileSync(e,postsArray,{encoding:"utf-8"}),process.exit(jobFailFlag?1:0)}let i=0;if(README_FILE_PATH_LIST.forEach(e=>{const t=fs.readFileSync(e,"utf8"),r=buildReadme(t,s);r!==t&&(core.info("Writing to "+e),fs.writeFileSync(e,r),i+=1)}),i>0)process.env.TEST_MODE||await commitReadme(GITHUB_TOKEN,README_FILE_PATH_LIST).then(()=>{process.exit(jobFailFlag?1:0)});else{if(!process.env.TEST_MODE&&ENABLE_KEEPALIVE){const e=core.getInput("committer_username"),t=core.getInput("committer_email"),r=await keepaliveWorkflow.KeepAliveWorkflow(GITHUB_TOKEN,e,t,"dummy commit to keep the repository active, see https://git.io/Jtm4V",50);core.info(r)}else core.info("No change detected, skipping");process.exit(jobFailFlag?1:0)}}catch(e){core.error(e),process.exit(1)}else core.info("0 blog posts fetched"),process.exit(jobFailFlag?1:0)}); },{"rss-parser":"BF6Y","@actions/core":"FTVr","dateformat":"FWyg","random-seed":"KFkI","promise-retry":"gnqO","keepalive-workflow":"EQNY","./utils":"FOZT","./filters":"KSDV"}]},{},["MHPq"], null) \ No newline at end of file diff --git a/package.json b/package.json index cdaf742..ecbd34a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blog-post-workflow", - "version": "1.6.4", + "version": "1.6.5", "description": "Allows you to show your latest blog posts on your github profile or project readme", "main": "blog-post-workflow.js", "scripts": {