diff --git a/dist/blog-post-workflow.js b/dist/blog-post-workflow.js index 7c1775d..939fe52 100644 --- a/dist/blog-post-workflow.js +++ b/dist/blog-post-workflow.js @@ -131,5 +131,5 @@ function t(t,e){var n=Object.keys(t);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;t{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 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]})});let post=_objectSpread({title:item.title.trim(),url:item.link.trim(),description:item.content?item.content:""},customTags);if(ENABLE_SORT&&(post.date=new Date(item.pubDate.trim())),ITEM_EXEC)try{eval(ITEM_EXEC)}catch(e){core.error("Failure in executing `item_exec` parameter"),core.error(e),process.exit(1)}if(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)}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),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=fs.readFileSync(README_FILE_PATH,"utf8"),r=core.getInput("template"),o=getParameterisedTemplate(r,"randomEmoji"),s=getParameterisedTemplate(r,"emojiKey"),n=postsArray.reduce((e,t,n)=>{if("default"===r)return e+`\n- [${t.title}](${t.url})`+(n+1===postsArray.length?"\n":"");{const i=dateFormat(t.date,core.getInput("date_format"));let a=r.replace(/\$title\b/g,t.title).replace(/\$url\b/g,t.url).replace(/\$description\b/g,t.description).replace(/\$date\b/g,i).replace(/\$newline/g,"\n");if(Object.keys(CUSTOM_TAGS).forEach(e=>{const r=t[e]?t[e]:"";a=a.replace(new RegExp("\\$"+e+"\\b","g"),r)}),o){const e=(process.env.GITHUB_REPOSITORY&&!process.env.TEST_MODE?process.env.GITHUB_REPOSITORY:"example")+n,t=o[rand.create(e).range(o.length)];a=a.replace(/\$randomEmoji\((\S)*\)/g,t)}return s&&(a=a.replace(/\$emojiKey\((\S)*\)/g,s[n%s.length])),e+a}},""),i="false"!==core.getInput("output_only"),a=i?null:buildReadme(t,n);if(a!==t)core.info("Writing to "+README_FILE_PATH),fs.writeFileSync(README_FILE_PATH,a),process.env.TEST_MODE||(i?(core.info("outputOnly mode: set `results` variable. Readme not committed."),core.setOutput("results",postsArray)):await commitReadme(GITHUB_TOKEN,README_FILE_PATH).then(()=>{process.exit(jobFailFlag?1:0)})),process.exit(jobFailFlag?1:0);else{const{outputData:e}=await exec("git",["--no-pager","log","-1","--format=%ct"],{encoding:"utf8",stdio:["pipe","pipe","pipe"]}),t=new Date(1e3*parseInt(e,10));Math.round((new Date-t)/864e5)>50&&!process.env.TEST_MODE&&ENABLE_KEEPALIVE?(core.info("Doing dummy commit to keep workflow active, see: https://git.io/Jtm4V"),await commitReadme(GITHUB_TOKEN,README_FILE_PATH,!0).then(()=>{process.exit(jobFailFlag?1:0)}),process.exit(0)):(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;t{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 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]})});let post=_objectSpread({title:item.title.trim(),url:item.link.trim(),description:item.content?item.content:""},customTags);if(ENABLE_SORT&&(post.date=new Date(item.pubDate.trim())),ITEM_EXEC)try{eval(ITEM_EXEC)}catch(e){core.error("Failure in executing `item_exec` parameter"),core.error(e),process.exit(1)}if(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)}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),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=fs.readFileSync(README_FILE_PATH,"utf8"),r=core.getInput("template"),o=getParameterisedTemplate(r,"randomEmoji"),s=getParameterisedTemplate(r,"emojiKey"),n=postsArray.reduce((e,t,n)=>{if("default"===r)return e+`\n- [${t.title}](${t.url})`+(n+1===postsArray.length?"\n":"");{const i=dateFormat(t.date,core.getInput("date_format"));let a=r.replace(/\$title\b/g,t.title).replace(/\$url\b/g,t.url).replace(/\$description\b/g,t.description).replace(/\$date\b/g,i).replace(/\$counter\b/g,(n+1).toString()).replace(/\$newline/g,"\n");if(Object.keys(CUSTOM_TAGS).forEach(e=>{const r=t[e]?t[e]:"";a=a.replace(new RegExp("\\$"+e+"\\b","g"),r)}),o){const e=(process.env.GITHUB_REPOSITORY&&!process.env.TEST_MODE?process.env.GITHUB_REPOSITORY:"example")+n,t=o[rand.create(e).range(o.length)];a=a.replace(/\$randomEmoji\((\S)*\)/g,t)}return s&&(a=a.replace(/\$emojiKey\((\S)*\)/g,s[n%s.length])),e+a}},""),i="false"!==core.getInput("output_only"),a=i?null:buildReadme(t,n);if(a!==t)core.info("Writing to "+README_FILE_PATH),fs.writeFileSync(README_FILE_PATH,a),process.env.TEST_MODE||(i?(core.info("outputOnly mode: set `results` variable. Readme not committed."),core.setOutput("results",postsArray)):await commitReadme(GITHUB_TOKEN,README_FILE_PATH).then(()=>{process.exit(jobFailFlag?1:0)})),process.exit(jobFailFlag?1:0);else{const{outputData:e}=await exec("git",["--no-pager","log","-1","--format=%ct"],{encoding:"utf8",stdio:["pipe","pipe","pipe"]}),t=new Date(1e3*parseInt(e,10));Math.round((new Date-t)/864e5)>50&&!process.env.TEST_MODE&&ENABLE_KEEPALIVE?(core.info("Doing dummy commit to keep workflow active, see: https://git.io/Jtm4V"),await commitReadme(GITHUB_TOKEN,README_FILE_PATH,!0).then(()=>{process.exit(jobFailFlag?1:0)}),process.exit(0)):(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","./utils":"FOZT","./filters":"KSDV"}]},{},["MHPq"], null) \ No newline at end of file diff --git a/package.json b/package.json index 5eca711..45f6f49 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blog-post-workflow", - "version": "1.5.6", + "version": "1.5.7", "description": "Allows you to show your latest blog posts on your github profile or project readme", "main": "blog-post-workflow.js", "scripts": {