diff --git a/README.md b/README.md index 3433811..a4bbc92 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ on: schedule: # Run workflow automatically - cron: '0 * * * *' # Runs every hour, on the hour - workflow_dispatch: # Run workflow manually (without waiting for the cron to be called), through the Github Actions Workflow page directly + workflow_dispatch: # Run workflow manually (without waiting for the cron to be called), through the GitHub Actions Workflow page directly jobs: update-readme-with-blog: @@ -35,48 +35,50 @@ feed_list: "https://dev.to/feed/gautamkrishnar,https://www.gautamkrishnar.com/feed/" ``` 1. Replace the above URL list with your own RSS feed URLs. See [popular-sources](#popular-sources) for a list of common RSS feed urls. -1. Commit and wait for it to run automatically or you can also trigger it manually to see the result instantly. To trigger the workflow manually, please follow the steps in the [video](https://www.youtube.com/watch?v=ECuqb5Tv9qI&t=272s). +1. Commit and wait for it to run automatically, or you can also trigger it manually to see the result instantly. To trigger the workflow manually, please follow the steps in the [video](https://www.youtube.com/watch?v=ECuqb5Tv9qI&t=272s). ## Options This workflow has additional options that you can use to customize it for your use case. The following are the list of options available: -| Option | Default Value | Description | Required | -|--------|--------|--------|--------| -| `feed_list` | `""` | Comma-separated list of RSS feed urls, eg: `https://example1.com,https://example2.com` | Yes | -| `max_post_count` | `5` | Maximum number of posts you want to show on your readme, all feeds combined | No | -| `readme_path` | `./README.md` | Comma separated paths of the readme files you want to update | No | -| `gh_token` | your GitHub token with repo scope | Use this to configure the token of the user that commits the workflow result to GitHub | No | -| `comment_tag_name` | `BLOG-POST-LIST` | Allows you to override the default comment tag name (``), if you want to show multiple instances of the action on the same repo, see advanced usage for more info | No | -| `disable_sort` | `false` | Disables the sorting of the list based on publish date | No | -| `feed_names` | `""` | Comma-separated list of RSS feed names, this is intended to be used with `template` option. eg: `Blog,Dev.to` | No | -| `template` | `default` | Allows you to change the structure of the posts list by using different variables. By default this workflow uses markdown list format to render the posts, you can override this behavior using this option. Eg: `[$title]($url) ` will give you a space-separated list of posts.

**Supported variables** | No | -| `categories_template` | `default` | By default `$categories` variable in the template is a comma separated string of categories. This option will allow you override it and customize the category item according to your use case. Following are the variables available: eg: `$category ` will show category list as `category1` `category2` `category3` etc | No | -| `date_format` | `UTC:ddd mmm dd yyyy h:MM TT` | Allows you to change the format of the date or time displayed when using the $date in the template option. This uses NPM dateformat library, please read the library [documentation](https://www.npmjs.com/package/dateformat#named-formats) for the supported formats | No | -| `user_agent` | `rss-parser` | Allows you to customize the user agent used by the RSS feed crawler | No | -| `accept_header` | `application/rss+xml` | Allows you to customize the accept header of the http requests | No | -| `tag_post_pre_newline` | `true` if you are not using **template** option | Allows you to insert a newline before the closing tag and after the opening tag when using the template option if needed, for better formatting | No | -| `filter_comments` | `medium,stackoverflow/Comment by $author/,stackexchange/Comment by $author/` | Comma separated list of platforms you want to enable the comment filter.

**Available filters** | No | -| `custom_tags` | `""` | Allows you to use the custom tags from your feed items in your template. Format: `variableName/tagName/,variableName/tagName/`. Please see the [issue comment](https://github.com/gautamkrishnar/blog-post-workflow/issues/28#issuecomment-696024087) for more details | No | -| `title_max_length` | `""` | Allows you to trim the title in the posts list, excess text will be appended with an ellipsis `...` | No | -| `description_max_length` | `""` | Allows you to trim the description in the posts list, excess text will be appended with an ellipsis `...` | No | -| `item_exec` | `""` | Allows you to execute custom JavaScript code on each post item fetched from the xml to do advanced text manipulation. Please see the [issue comment](https://github.com/gautamkrishnar/blog-post-workflow/issues/34#issuecomment-706582788) as an example | No | -| `commit_message` | `Updated with the latest blog posts` | Allows you to customize the commit message | No | -| `committer_username` | `blog-post-bot` | Allows you to customize the committer username | No | -| `committer_email` | `blog-post-bot@example.com` | Allows you to customize the committer email | No | -| `output_only` | `false` | Sets the generated array as `results` [output variable](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs) so that it can be consumed in other actions and parsed via utilities like [jq](https://stedolan.github.io/jq/). This will also prevent committing to readme. See [#51](https://github.com/gautamkrishnar/blog-post-workflow/issues/51#issuecomment-758570235) for more details about the output format and how to use it. This will also generate a JSON file named `/tmp/blog_post_workflow_output.json` that you can use to consume the generated data and avoid issues like [#110](https://github.com/gautamkrishnar/blog-post-workflow/issues/110). | No | -| `enable_keepalive` | `true` | Workflow will automatically do a dummy commit to keep the repository active if there is no commit activity for the last 50 days. GitHub will stop running all cron based triggers if the repository is not active for more than 60 days. This flag allows you to disable this feature. See [#53](https://git.io/Jtm4V) for more details. | No | -| `retry_count` | `0` | Maximum number of times to retry the fetch operation if it fails, See [#66](https://github.com/gautamkrishnar/blog-post-workflow/issues/66) for more details. | No | -| `retry_wait_time` | `1` | Time to wait before each retry operation in seconds. | No | -| `disable_html_encoding` | `false` | Disables html encoding of the feed contents. | No | -| `disable_item_validation` | `false` | Disables the validation checks for Title, publish date and URL. | No | -| `filter_dates` | `""` | Allows you to filter post items based on date range.

**Supported Values** Make sure that you set the `max_post_count` to a higher value to get rid of max post count filtering, before using the above options. | No | +| Option | Default Value | Description | Required | +|---------------------------|------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------| +| `feed_list` | `""` | Comma-separated list of RSS feed urls, eg: `https://example1.com,https://example2.com` | Yes | +| `max_post_count` | `5` | Maximum number of posts you want to show on your readme, all feeds combined | No | +| `readme_path` | `./README.md` | Comma separated paths of the readme files you want to update | No | +| `gh_token` | your GitHub token with repo scope | Use this to configure the token of the user that commits the workflow result to GitHub | No | +| `comment_tag_name` | `BLOG-POST-LIST` | Allows you to override the default comment tag name (``), if you want to show multiple instances of the action on the same repo, see advanced usage for more info | No | +| `disable_sort` | `false` | Disables the sorting of the list based on publish date | No | +| `feed_names` | `""` | Comma-separated list of RSS feed names, this is intended to be used with `template` option. eg: `Blog,Dev.to` | No | +| `template` | `default` | Allows you to change the structure of the posts list by using different variables. By default this workflow uses markdown list format to render the posts, you can override this behavior using this option. Eg: `[$title]($url) ` will give you a space-separated list of posts.

**Supported variables** | No | +| `categories_template` | `default` | By default `$categories` variable in the template is a comma separated string of categories. This option will allow you override it and customize the category item according to your use case. Following are the variables available: eg: `$category ` will show category list as `category1` `category2` `category3` etc | No | +| `date_format` | `UTC:ddd mmm dd yyyy h:MM TT` | Allows you to change the format of the date or time displayed when using the $date in the template option. This uses NPM dateformat library, please read the library [documentation](https://www.npmjs.com/package/dateformat#named-formats) for the supported formats | No | +| `user_agent` | `rss-parser` | Allows you to customize the user agent used by the RSS feed crawler | No | +| `accept_header` | `application/rss+xml` | Allows you to customize the accept header of the http requests | No | +| `tag_post_pre_newline` | `true` if you are not using **template** option | Allows you to insert a newline before the closing tag and after the opening tag when using the template option if needed, for better formatting | No | +| `filter_comments` | `medium,stackoverflow/Comment by $author/,stackexchange/Comment by $author/` | Comma separated list of platforms you want to enable the comment filter.

**Available filters** | No | +| `custom_tags` | `""` | Allows you to use the custom tags from your feed items in your template. Format: `variableName/tagName/,variableName/tagName/`. Please see the [issue comment](https://github.com/gautamkrishnar/blog-post-workflow/issues/28#issuecomment-696024087) for more details | No | +| `title_max_length` | `""` | Allows you to trim the title in the posts list, excess text will be appended with an ellipsis `...` | No | +| `description_max_length` | `""` | Allows you to trim the description in the posts list, excess text will be appended with an ellipsis `...` | No | +| `item_exec` | `""` | Allows you to execute custom JavaScript code on each post item fetched from the xml to do advanced text manipulation. Please see the [issue comment](https://github.com/gautamkrishnar/blog-post-workflow/issues/34#issuecomment-706582788) as an example | No | +| `commit_message` | `Updated with the latest blog posts` | Allows you to customize the commit message | No | +| `committer_username` | `blog-post-bot` | Allows you to customize the committer username | No | +| `committer_email` | `blog-post-bot@example.com` | Allows you to customize the committer email | No | +| `output_only` | `false` | Sets the generated array as `results` [output variable](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idoutputs) so that it can be consumed in other actions and parsed via utilities like [jq](https://stedolan.github.io/jq/). This will also prevent committing to readme. See [#51](https://github.com/gautamkrishnar/blog-post-workflow/issues/51#issuecomment-758570235) for more details about the output format and how to use it. This will also generate a JSON file named `/tmp/blog_post_workflow_output.json` that you can use to consume the generated data and avoid issues like [#110](https://github.com/gautamkrishnar/blog-post-workflow/issues/110). | No | +| `enable_keepalive` | `true` | Workflow will automatically do a dummy commit to keep the repository active if there is no commit activity for the last 50 days. GitHub will stop running all cron based triggers if the repository is not active for more than 60 days. This flag allows you to disable this feature. See [#53](https://git.io/Jtm4V) for more details. | No | +| `retry_count` | `0` | Maximum number of times to retry the fetch operation if it fails, See [#66](https://github.com/gautamkrishnar/blog-post-workflow/issues/66) for more details. | No | +| `retry_wait_time` | `1` | Time to wait before each retry operation in seconds. | No | +| `disable_html_encoding` | `false` | Disables html encoding of the feed contents. | No | +| `disable_item_validation` | `false` | Disables the validation checks for Title, publish date and URL. | No | +| `filter_dates` | `""` | Allows you to filter post items based on date range.

**Supported Values** Make sure that you set the `max_post_count` to a higher value to get rid of max post count filtering, before using the above options. | No | +| `rand_seed` | `"username/repository"` | Provide your own seeding string for the randomness. More info: [#152](https://github.com/gautamkrishnar/blog-post-workflow/issues/152) | No | + ## Advanced usage examples ### StackOverflow example -The following configuration allows you to show your latest StackOverflow activity along with your latest blog posts in the Github profile or project readme: +The following configuration allows you to show your latest StackOverflow activity along with your latest blog posts in the GitHub profile or project readme: 1. Follow the steps mentioned in the [how to use](#how-to-use) section. 1. Add the following section to your **README.md** file, you can give whatever title you want. Just make sure that you use `` in your readme. The workflow will replace this comment with the actual StackOverflow activity: @@ -117,28 +119,28 @@ The following configuration allows you to show your latest StackOverflow activit Some popular blogging platforms and their RSS feed URLs: -| Name | Feed URL | Comments | Example | -|--------|--------|--------|--------| -| [Dev.to](https://dev.to/) | `https://dev.to/feed/username` | Replace username with your own username | https://dev.to/feed/gautamkrishnar | -| [Wordpress](https://wordpress.org/) | `https://www.example.com/feed/` | Replace with your own blog url | https://www.gautamkrishnar.com/feed/ | -| [Medium](https://medium.com/) | `https://medium.com/feed/@username` | Replace username with your Medium username | https://medium.com/feed/@khaosdoctor | -| [Medium (Sub Domain)](https://medium.com/) | `https://username.medium.com/feed` | Replace username with your Medium username | https://timsneath.medium.com/feed | -| [Stackoverflow](https://stackoverflow.com/) | `https://stackoverflow.com/feeds/user/userid` | Replace with your StackOverflow [UserId](https://meta.stackexchange.com/questions/98771/what-is-my-user-id/111130#111130) | https://stackoverflow.com/feeds/user/5283532 | -| [StackExchange](https://stackexchange.com/) | `https://subdomain.stackexchange.com/feeds/user/userid` | Replace with your StackExchange [UserId](https://meta.stackexchange.com/questions/98771/what-is-my-user-id/111130#111130) and sub-domain | https://devops.stackexchange.com/feeds/user/15 | -| [Ghost](https://ghost.org/) | `https://www.example.com/rss/` | Replace with your own blog url | https://blog.codinghorror.com/rss/ | -| [Drupal](https://www.drupal.org/) | `https://www.example.com/rss.xml` | Replace with your own blog url | https://www.arsenal.com/rss.xml | -| [Youtube Playlists](https://www.youtube.com) | `https://www.youtube.com/feeds/videos.xml?playlist_id=playlistId` | Replace `playlistId` with your own Youtube playlist id | https://www.youtube.com/feeds/videos.xml?playlist_id=PLJNqgDLpd5E69Kc664st4j7727sbzyx0X | -| [Youtube Channel Video list](https://www.youtube.com) | `https://www.youtube.com/feeds/videos.xml?channel_id=channelId` | Replace `channelId` with your own Youtube channel id | https://www.youtube.com/feeds/videos.xml?channel_id=UCDCHcqyeQgJ-jVSd6VJkbCw | -| [Anchor.fm Podcasts](https://anchor.fm/) | `https://anchor.fm/s/podcastId/podcast/rss` | You can get the rss feed url of a podcast by following [these](https://help.anchor.fm/hc/en-us/articles/360027712351-Locating-your-Anchor-RSS-feed) instructions | https://anchor.fm/s/1e784a38/podcast/rss | -| [Hashnode](https://hashnode.com/) | `https://@username.hashnode.dev/rss.xml` | Replace @username with your Hashnode username | https://polilluminato.hashnode.dev/rss.xml | -| [Google Podcasts](https://podcasts.google.com/) | `https://podcasts.google.com/feed/channelId` | Replace `channelId` with your Google podcast channel Id | https://podcasts.google.com/feed/aHR0cHM6Ly9mZWVkcy5zb3VuZGNsb3VkLmNvbS91c2Vycy9zb3VuZGNsb3VkOnVzZXJzOjYyOTIxMTkwL3NvdW5kcy5yc3M= | -| [Reddit](https://www.reddit.com/) | `http://www.reddit.com/r/topic/.rss` | You can create an RSS feed by adding '.rss' to the end of an existing Reddit URL. Replace `topic` with SubReddit topic that interest you or localized to you.| http://www.reddit.com/r/news/.rss | -| [Analytics India Magazine](https://analyticsindiamag.com/) | `https://analyticsindiamag.com/author/author_name/feed/` | Replace `author_name` with your name | https://analyticsindiamag.com/author/kaustubhgupta1828gmail-com/feed/ | -| [Feedburner](https://feedburner.com/) | `https://feeds.feedburner.com/feed_address` | Replace `feed_address` with your Feedburner feed address | https://feeds.feedburner.com/darkwood-fr/blog | -| [Tumblr](https://www.tumblr.com)|`https://blog_name.tumblr.com/rss` or `https://example.com/rss`|You can create an RSS feed by adding '/rss' to your main blog page or to your own domain if it is configured. Replace `blog_name` with your blog name | https://goggledoddle.tumblr.com/rss| -| [Blogger](https://www.blogger.com/)|`https://blog_name.blogspot.com/feeds/posts/default` | Replace `blog_name` with your blog subdomain | https://singlebucks.blogspot.com/feeds/posts/default | -| [Velog](https://velog.io/) |`https://v2.velog.io/rss/userid` | Replace `userid` with your user id (without the @ symbol) | https://v2.velog.io/rss/minnczi | -| [Shouts.dev](https://shouts.dev/) |`https://shouts.dev/feed/username` | Replace `username` with your own username | https://shouts.dev/feed/obydul | +| Name | Feed URL | Comments | Example | +|------------------------------------------------------------|-------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------| +| [Dev.to](https://dev.to/) | `https://dev.to/feed/username` | Replace username with your own username | https://dev.to/feed/gautamkrishnar | +| [Wordpress](https://wordpress.org/) | `https://www.example.com/feed/` | Replace with your own blog url | https://www.gautamkrishnar.com/feed/ | +| [Medium](https://medium.com/) | `https://medium.com/feed/@username` | Replace username with your Medium username | https://medium.com/feed/@khaosdoctor | +| [Medium (Sub Domain)](https://medium.com/) | `https://username.medium.com/feed` | Replace username with your Medium username | https://timsneath.medium.com/feed | +| [Stackoverflow](https://stackoverflow.com/) | `https://stackoverflow.com/feeds/user/userid` | Replace with your StackOverflow [UserId](https://meta.stackexchange.com/questions/98771/what-is-my-user-id/111130#111130) | https://stackoverflow.com/feeds/user/5283532 | +| [StackExchange](https://stackexchange.com/) | `https://subdomain.stackexchange.com/feeds/user/userid` | Replace with your StackExchange [UserId](https://meta.stackexchange.com/questions/98771/what-is-my-user-id/111130#111130) and sub-domain | https://devops.stackexchange.com/feeds/user/15 | +| [Ghost](https://ghost.org/) | `https://www.example.com/rss/` | Replace with your own blog url | https://blog.codinghorror.com/rss/ | +| [Drupal](https://www.drupal.org/) | `https://www.example.com/rss.xml` | Replace with your own blog url | https://www.arsenal.com/rss.xml | +| [Youtube Playlists](https://www.youtube.com) | `https://www.youtube.com/feeds/videos.xml?playlist_id=playlistId` | Replace `playlistId` with your own Youtube playlist id | https://www.youtube.com/feeds/videos.xml?playlist_id=PLJNqgDLpd5E69Kc664st4j7727sbzyx0X | +| [Youtube Channel Video list](https://www.youtube.com) | `https://www.youtube.com/feeds/videos.xml?channel_id=channelId` | Replace `channelId` with your own Youtube channel id | https://www.youtube.com/feeds/videos.xml?channel_id=UCDCHcqyeQgJ-jVSd6VJkbCw | +| [Anchor.fm Podcasts](https://anchor.fm/) | `https://anchor.fm/s/podcastId/podcast/rss` | You can get the rss feed url of a podcast by following [these](https://help.anchor.fm/hc/en-us/articles/360027712351-Locating-your-Anchor-RSS-feed) instructions | https://anchor.fm/s/1e784a38/podcast/rss | +| [Hashnode](https://hashnode.com/) | `https://@username.hashnode.dev/rss.xml` | Replace @username with your Hashnode username | https://polilluminato.hashnode.dev/rss.xml | +| [Google Podcasts](https://podcasts.google.com/) | `https://podcasts.google.com/feed/channelId` | Replace `channelId` with your Google podcast channel Id | https://podcasts.google.com/feed/aHR0cHM6Ly9mZWVkcy5zb3VuZGNsb3VkLmNvbS91c2Vycy9zb3VuZGNsb3VkOnVzZXJzOjYyOTIxMTkwL3NvdW5kcy5yc3M= | +| [Reddit](https://www.reddit.com/) | `http://www.reddit.com/r/topic/.rss` | You can create an RSS feed by adding '.rss' to the end of an existing Reddit URL. Replace `topic` with SubReddit topic that interest you or localized to you. | http://www.reddit.com/r/news/.rss | +| [Analytics India Magazine](https://analyticsindiamag.com/) | `https://analyticsindiamag.com/author/author_name/feed/` | Replace `author_name` with your name | https://analyticsindiamag.com/author/kaustubhgupta1828gmail-com/feed/ | +| [Feedburner](https://feedburner.com/) | `https://feeds.feedburner.com/feed_address` | Replace `feed_address` with your Feedburner feed address | https://feeds.feedburner.com/darkwood-fr/blog | +| [Tumblr](https://www.tumblr.com) | `https://blog_name.tumblr.com/rss` or `https://example.com/rss` | You can create an RSS feed by adding '/rss' to your main blog page or to your own domain if it is configured. Replace `blog_name` with your blog name | https://goggledoddle.tumblr.com/rss | +| [Blogger](https://www.blogger.com/) | `https://blog_name.blogspot.com/feeds/posts/default` | Replace `blog_name` with your blog subdomain | https://singlebucks.blogspot.com/feeds/posts/default | +| [Velog](https://velog.io/) | `https://v2.velog.io/rss/userid` | Replace `userid` with your user id (without the @ symbol) | https://v2.velog.io/rss/minnczi | +| [Shouts.dev](https://shouts.dev/) | `https://shouts.dev/feed/username` | Replace `username` with your own username | https://shouts.dev/feed/obydul | ### Examples @@ -174,15 +176,15 @@ If you are experiencing any bugs, donโ€™t forget to open a [new issue](https://g - Everyone for making this project the top 20 most installed / starred action in the [GitHub Marketplace](https://github.com/marketplace?category=&query=sort%3Apopularity-desc&type=actions&verification=) - All the [contributors](https://github.com/gautamkrishnar/blog-post-workflow/graphs/contributors) - [@codeSTACKr](https://github.com/codeSTACKr) for [this](https://www.youtube.com/watch?v=ECuqb5Tv9qI) amazing video -- [CodeCov](https://about.codecov.io/) for this blog: [Discovering the Most Popular and Most Used Github Actions](https://about.codecov.io/blog/discovering-the-most-popular-and-most-used-github-actions/) +- [CodeCov](https://about.codecov.io/) for this blog: [Discovering the Most Popular and Most Used GitHub Actions](https://about.codecov.io/blog/discovering-the-most-popular-and-most-used-github-actions/) - [the byte podcast](https://podcast.thebyte.io/episodes/learn-how-to-pimp-out-your-github-profile) - **JetBrains** for sponsoring the Open Source License to my favourite IDE WebStorm: - + jetbrains - - Thanks @github for [GitHub India Open Source Grants](https://github.blog/2021-09-12-recipients-open-source-grants-github-sponsors-india/) and for sponsoring me + - Thanks [@github](https://github.com/github), for [GitHub India Open Source Grants](https://github.blog/2021-09-12-recipients-open-source-grants-github-sponsors-india/) and for sponsoring me ## Liked it? diff --git a/action.yml b/action.yml index 86c36bc..f8e99f7 100644 --- a/action.yml +++ b/action.yml @@ -113,6 +113,10 @@ inputs: description: "Enables date filters" default: "" required: false + rand_seed: + description: "Provide your own seeding string for the randomness" + default: "" + required: false outputs: results: description: "JSON stringified array of posts" diff --git a/local-run.js b/local-run.js index d8f887d..3b322f3 100644 --- a/local-run.js +++ b/local-run.js @@ -33,6 +33,7 @@ fs.writeFile(path.join(__dirname, 'test', 'Readme.md'), template, () => { process.env.INPUT_RETRY_WAIT_TIME = '1'; process.env.INPUT_DISABLE_ITEM_VALIDATION = 'false'; process.env.INPUT_FILTER_DATES = ''; + process.env.INPUT_RAND_SEED = ''; const testFile = process.env.DIST ? './dist/blog-post-workflow' : './src/blog-post-workflow'; console.log('Testing: ', testFile); require(testFile); diff --git a/src/blog-post-workflow.js b/src/blog-post-workflow.js index 33a157a..5b5bba3 100644 --- a/src/blog-post-workflow.js +++ b/src/blog-post-workflow.js @@ -275,8 +275,12 @@ Promise.allSettled(promiseArray).then((results) => { // Emoji implementation: Random if (randEmojiArr) { // For making randomness unique for each repos - const seed = (process.env.GITHUB_REPOSITORY && !process.env.TEST_MODE ? + let seed = (process.env.GITHUB_REPOSITORY && !process.env.TEST_MODE ? process.env.GITHUB_REPOSITORY : 'example') + index; + if (core.getInput('rand_seed')) { + // If manual seed is provided, use it + seed = core.getInput('rand_seed') + index; + } const emoji = randEmojiArr[rand.create(seed).range(randEmojiArr.length)]; content = content.replace(/\$randomEmoji\((\S)*\)/g, emoji); } diff --git a/test/test.js b/test/test.js index b37e68a..f7a0ea1 100644 --- a/test/test.js +++ b/test/test.js @@ -28,7 +28,8 @@ const DEFAULT_TEST_ENV = { TEST_MODE: 'true', INPUT_CATEGORIES_TEMPLATE: 'default', INPUT_DISABLE_ITEM_VALIDATION: 'false', - INPUT_FILTER_DATES: '' + INPUT_FILTER_DATES: '', + INPUT_RAND_SEED: '' }; // Folder with readme snapshots