{"componentChunkName":"component---src-templates-blog-post-js","path":"/blog/executing-markdown-codeblocks-with-github-actions","result":{"data":{"markdownRemark":{"excerpt":"Let's get started, so you might say what are we going to do? Let's break it down:- We are going to create a GithubAction which will extract…","html":"<p>Let's get started, so you might say what are we going to do? Let's break it down:-</p>\n<p>We are going to create a <a href=\"https://github.com/features/actions\">GithubAction</a> which will extract the markdown codeblock\n<em>(js)</em> from the specified repo's issues and then execute the javascript and add a comment with the output.</p>\n<p><figure class=\"gatsby-resp-image-figure\" style=\"\">\n    <span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 590px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/0641dafad61797d720dcbfc4233bc5d7/63ec5/issue_example.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 60.810810810810814%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsTAAALEwEAmpwYAAABm0lEQVQoz5WS224TMRCG8/7XfQOu2wuEgIeouOhNERVUAiXdbjZZn8/23xnvEhJRQFj6NDP2+Lc9401rDUEHJB0xzwJCCCilu+V4u91BUpxyBg/O/xsbTrr+9hFXd2+wG57wtBswjvvONE0YhgFSKjjnUUrBv0YXvB3v8Wn+jBAjfIhkE2LKSKkQufveL/Oltj9S63rDm+t3ePzyHZMK+PE8YxRuYbbYC49nstJXUFWgQruA84ajxSg9YiHBRoLOGbpZ6LWSWkMbElCmx0obiNUqbVcM5bhXb7nhQvKoZK2NJOIhKVkRkjY7z2VIvRQLaYGeH+JSjrCWpZ4L8gghw7oEQyIsZB11P5eFVE5+PPPPOdXw7v4B4zTDp0pifHqBW7F0CM+H3C7gORvKCc4tPwXfvv+Ah6+POFBTtqOgRjhMVOQDPZ996QsMNUTH1mFfutIbdlARe+n63qUpZ0+WUvYPfTwekdePTF+Zf/PvoP1aXy33YcNrtVa6boWydKIwOEhDz0iwfsGF1+nr3cYeX3aZglxqp6z2f2GNF9NmpT2f9p1HAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"GithubAction automatically executes the code\"\n        title=\"GithubAction automatically executes the code\"\n        src=\"/static/0641dafad61797d720dcbfc4233bc5d7/fcda8/issue_example.png\"\n        srcset=\"/static/0641dafad61797d720dcbfc4233bc5d7/12f09/issue_example.png 148w,\n/static/0641dafad61797d720dcbfc4233bc5d7/e4a3f/issue_example.png 295w,\n/static/0641dafad61797d720dcbfc4233bc5d7/fcda8/issue_example.png 590w,\n/static/0641dafad61797d720dcbfc4233bc5d7/63ec5/issue_example.png 812w\"\n        sizes=\"(max-width: 590px) 100vw, 590px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n  </a>\n    </span>\n    <figcaption class=\"gatsby-resp-image-figcaption\">GithubAction automatically executes the code</figcaption>\n  </figure></p>\n<h2 id=\"Setting-Up\" style=\"position:relative;\"><a href=\"#Setting-Up\" aria-label=\"Setting Up permalink\" class=\"gatsby-remark-autolink before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Setting Up</h2>\n<p>Let's start simply by installing all the required dependencies first.</p>\n<p><strong>Initialize NPM:</strong></p>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-sh line-numbers\"><code class=\"language-sh\">npm init</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p><strong>Installing dependencies:</strong></p>\n<ul>\n<li><a href=\"https://www.npmjs.com/package/@octokit/rest\">@octokit/rest</a></li>\n<li><a href=\"https://www.npmjs.com/package/markdown-parser\">markdown-parser</a></li>\n<li><a href=\"https://www.npmjs.com/package/vm2\">vm2</a></li>\n<li><a href=\"https://www.npmjs.com/package/dotenv\">dotenv</a></li>\n</ul>\n<p>We are going to use <a href=\"https://www.npmjs.com/package/@octokit/rest\">@octokit/rest</a> for fetching all the issues and for\ncommenting on the issues. octokit/rest provides a very nice wrapper around\n<a href=\"https://developer.github.com/v3/\">Github's API</a>.</p>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-sh line-numbers\"><code class=\"language-sh\">npm i @octokit/rest</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>To parse the markdown and extract the codeblock we are also going to install\n<a href=\"https://www.npmjs.com/package/markdown-parser\">markdown-parser</a>.</p>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-sh line-numbers\"><code class=\"language-sh\">npm i markdown-parser</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Now maybe the most crucial package for this project, <code class=\"language-text\">vm2</code>.</p>\n<p>vm2 is a sandbox that can run untrusted code with whitelisted Node's built-in modules. Securely!</p>\n<blockquote>\n<p>If you don't use vm2 then, someone could actually log your environment variables and get your access token and also execute any malicious code.</p>\n</blockquote>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-sh line-numbers\"><code class=\"language-sh\">npm i vm2</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Okay! Now we have everything set up nicely, let's get started.</p>\n<h2 id=\"Setting-up-environment-variables\" style=\"position:relative;\"><a href=\"#Setting-up-environment-variables\" aria-label=\"Setting up environment variables permalink\" class=\"gatsby-remark-autolink before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Setting up environment variables</h2>\n<p>To use Github's API to create comments and fetch the issues we are going to need a <strong>Personal Access Token\n(PERSONAL_TOKEN)</strong></p>\n<p>Here's how you can\n<a href=\"https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line\">create your Personal Access Token</a></p>\n<blockquote>\n<p>You should <em>not upload, share, or give Personal Access Tokens</em> to anyone. Otherwise, someone could get access to your\nGitHub account.</p>\n</blockquote>\n<p><strong>Using personal access token in local development:</strong></p>\n<p>For this, we are going to use <code class=\"language-text\">dotenv</code></p>\n<p>In your root directory create a file called <code class=\"language-text\">.env</code> (without extension) and add this line to it with your personal token\nwhich you generated previously.</p>\n<p>After that, you should also create a\n<a href=\"https://github.com/anuraghazra/GithubActionsPlayground/blob/master/.gitignore\">.gitignore</a> file so that your .env wont\nget uploaded in GitHub.</p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-text line-numbers\"><code class=\"language-text\">PERSONAL_TOKEN=yourtoken123</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>And then, in index.js file require the dotenv module.</p>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token comment\">// index.js</span>\n<span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">'dotenv'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">config</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p>You might say okay that would work in my local machine but how will GitHub know about my personal access token then?\nThe answer is GitHub secrets.</p>\n<p>To add a secret env variable to your GitHub repo go to your repo settings and you'll see a <code class=\"language-text\">secrets</code> tab like this and\nClick \"Add a new secret\".</p>\n<p><figure class=\"gatsby-resp-image-figure\" style=\"\">\n    <span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 590px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/2460e1c56c4d13f5ac9a9f559530092a/1be7e/github-secrets.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 50%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsTAAALEwEAmpwYAAABEklEQVQoz5VS7W7EIAzj/V9zv07a1hYIH4XgGVhP7Z0mrZGspE1r7ASTckaICV7CJYcwa+dlZAlxYNbs8f32+EDYvrCXirwX7ISJqSDlgloroSilYFlW/hTQo7U2cK4PKF/rbD37RlLFJpWN2VFVrOsGay1VBnhCRPjsqE5G7WWqjjEipTS+y3Taw/hQYAnyz1NJ2G1u1mOlUrsscCTrBzjv4Rxrxyz56ay76nkSRlp0BYV2dVhRzkMR9oads1ISoZ18XaK9jYGWFd8k7NY76ZzXgd+qtX/DDDs+PYeqejRPC/lT4XuYGDPXrsNq33KfIW6quihcbcDjc4PEfh/zuFOv1+VOmMhNWdm5iDrUvSq8Gz9OdhPCNPU5xgAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Github, adding a new repo secret (click to enlarge)\"\n        title=\"Github, adding a new repo secret (click to enlarge)\"\n        src=\"/static/2460e1c56c4d13f5ac9a9f559530092a/fcda8/github-secrets.png\"\n        srcset=\"/static/2460e1c56c4d13f5ac9a9f559530092a/12f09/github-secrets.png 148w,\n/static/2460e1c56c4d13f5ac9a9f559530092a/e4a3f/github-secrets.png 295w,\n/static/2460e1c56c4d13f5ac9a9f559530092a/fcda8/github-secrets.png 590w,\n/static/2460e1c56c4d13f5ac9a9f559530092a/efc66/github-secrets.png 885w,\n/static/2460e1c56c4d13f5ac9a9f559530092a/1be7e/github-secrets.png 1059w\"\n        sizes=\"(max-width: 590px) 100vw, 590px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n  </a>\n    </span>\n    <figcaption class=\"gatsby-resp-image-figcaption\">Github, adding a new repo secret (click to enlarge)</figcaption>\n  </figure></p>\n<p>After clicking \"Add a new secret\" add a name of the secret \"PERSONAL_TOKEN\" and in value field, add your token.</p>\n<p><figure class=\"gatsby-resp-image-figure\" style=\"\">\n    <span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 590px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/98b7739fba85cf36c6772e6f3a2d4c3b/5e3a3/github-secrets2.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 76.35135135135135%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAAsTAAALEwEAmpwYAAABbElEQVQ4y62SSW7DMAxFfeHeoOuue6L2CgW66iJdFGniObIla6LkX8pxRqRDghJ4pklBn5TETEqJ5ecKUir8h2XOOUg1QBsDM2GhtZ7+U04pNec51rt1s89NWIth0AghIEsbiiJH2zaoyhLrPGdfoawq5MUcVzXHNfK8QNW0yGuFVgyXBeM4whKgbYT1ERxONt5w3JE3Z94ThNQsNoLifukHDpvPiTGyIBGW6wZFLVE2Em3v0OuIbghMPCJAsDeDQ+y6rciRcLJJkChgVQpUQk90OkCZEdLEExTTc97qg+C5xTgmQcKGL3zoe3ghQDxG6XK/hbsg1kqN7PCzD4E7TB/VS4h2g6FuYLoezgeGrobSK6eqxKLE7fK7wCfPi36u/GeOBc8rXS1G4bTDbYXZc7e3HPdE0JCfsDzxlu/SW3dbh+yz1grcvz7i7uUBz4snQFqEMV4c3N/YDnYgLMQH3tp3CCf3A5pm6noivgCX0pXn8EzNAgAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Github, adding a new repo secret 2 (click to enlarge)\"\n        title=\"Github, adding a new repo secret 2 (click to enlarge)\"\n        src=\"/static/98b7739fba85cf36c6772e6f3a2d4c3b/fcda8/github-secrets2.png\"\n        srcset=\"/static/98b7739fba85cf36c6772e6f3a2d4c3b/12f09/github-secrets2.png 148w,\n/static/98b7739fba85cf36c6772e6f3a2d4c3b/e4a3f/github-secrets2.png 295w,\n/static/98b7739fba85cf36c6772e6f3a2d4c3b/fcda8/github-secrets2.png 590w,\n/static/98b7739fba85cf36c6772e6f3a2d4c3b/5e3a3/github-secrets2.png 763w\"\n        sizes=\"(max-width: 590px) 100vw, 590px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n  </a>\n    </span>\n    <figcaption class=\"gatsby-resp-image-figcaption\">Github, adding a new repo secret 2 (click to enlarge)</figcaption>\n  </figure></p>\n<p>Now we are all good to go, let's get started with the coding now.</p>\n<h2 id=\"Lets-Code-Now\" style=\"position:relative;\"><a href=\"#Lets-Code-Now\" aria-label=\"Lets Code Now permalink\" class=\"gatsby-remark-autolink before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Let's Code Now</h2>\n<p>In the index.js file, we are going to require all the necessary dependencies 1st</p>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token comment\">// index.js</span>\n<span class=\"token keyword\">const</span> Octokit <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">'@octokit/rest'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">const</span> Parser <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">'markdown-parser'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n<span class=\"token keyword\">const</span> <span class=\"token punctuation\">{</span> <span class=\"token constant\">VM</span> <span class=\"token punctuation\">}</span> <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">'vm2'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">'dotenv'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">config</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Now let's also initialize <code class=\"language-text\">VM2</code></p>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token comment\">// index.js</span>\n\n<span class=\"token comment\">// initialize VM</span>\n<span class=\"token keyword\">const</span> vm <span class=\"token operator\">=</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">VM</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n  timeout<span class=\"token operator\">:</span> <span class=\"token number\">1000</span><span class=\"token punctuation\">,</span>\n  sandbox<span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\n  eval<span class=\"token operator\">:</span> <span class=\"token boolean\">false</span><span class=\"token punctuation\">,</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>To work with Octokit let's authorize our PERSONAL_TOKEN and initialize Octokit, and also let's initialize\nmarkdown-parser</p>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token comment\">// index.js</span>\n\n<span class=\"token comment\">// initialize markdown-parser</span>\n<span class=\"token keyword\">const</span> parser <span class=\"token operator\">=</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">Parser</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n<span class=\"token comment\">// initialize octokit</span>\n<span class=\"token keyword\">const</span> octokit <span class=\"token operator\">=</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">Octokit</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n  auth<span class=\"token operator\">:</span> process<span class=\"token punctuation\">.</span>env<span class=\"token punctuation\">.</span><span class=\"token constant\">PERSONAL_TOKEN</span><span class=\"token punctuation\">,</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"Octokit\" style=\"position:relative;\"><a href=\"#Octokit\" aria-label=\"Octokit permalink\" class=\"gatsby-remark-autolink before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Octokit</h2>\n<p><strong>Listing all the issues in the repo:</strong></p>\n<p>To get all the issues of our repo, we are going to use octokit's API to fetch them.</p>\n<p>You may have noticed we also used an <a href=\"https://javascript.info/async-await\">async function</a> to make things nice and\nclean.</p>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token comment\">// index.js</span>\n\n<span class=\"token comment\">// get data</span>\n<span class=\"token punctuation\">(</span><span class=\"token keyword\">async</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">const</span> <span class=\"token punctuation\">{</span> data<span class=\"token operator\">:</span> issuesRes <span class=\"token punctuation\">}</span> <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> octokit<span class=\"token punctuation\">.</span>issues<span class=\"token punctuation\">.</span><span class=\"token function\">listForRepo</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n    owner<span class=\"token operator\">:</span> <span class=\"token string\">'username'</span><span class=\"token punctuation\">,</span>\n    repo<span class=\"token operator\">:</span> <span class=\"token string\">'my-awesome-repo'</span><span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n  console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>issuesRes<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> <span class=\"token comment\">// all issues</span>\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Now we need to loop through all the issues and parse the markdown to find the <code class=\"language-text\">markdown codeblock</code> and use <code class=\"language-text\">vm.run()</code> to run the codeblock.</p>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token comment\">// index.js</span>\n\n<span class=\"token comment\">// get data</span>\n<span class=\"token punctuation\">(</span><span class=\"token keyword\">async</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">const</span> <span class=\"token punctuation\">{</span> data<span class=\"token operator\">:</span> issuesRes <span class=\"token punctuation\">}</span> <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> octokit<span class=\"token punctuation\">.</span>issues<span class=\"token punctuation\">.</span><span class=\"token function\">listForRepo</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n    owner<span class=\"token operator\">:</span> <span class=\"token string\">'username'</span><span class=\"token punctuation\">,</span>\n    repo<span class=\"token operator\">:</span> <span class=\"token string\">'my-awesome-repo'</span><span class=\"token punctuation\">,</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n  <span class=\"token comment\">// loop thought all the issues NOTE: PR are also considered as issues</span>\n  issuesRes<span class=\"token punctuation\">.</span><span class=\"token function\">forEach</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">issue<span class=\"token punctuation\">,</span> index</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\n    <span class=\"token keyword\">let</span> issueNumber <span class=\"token operator\">=</span> issue<span class=\"token punctuation\">.</span>number<span class=\"token punctuation\">;</span>\n    <span class=\"token keyword\">let</span> issueBody <span class=\"token operator\">=</span> issue<span class=\"token punctuation\">.</span>body<span class=\"token punctuation\">;</span>\n\n    <span class=\"token comment\">// parse markdown</span>\n    parser<span class=\"token punctuation\">.</span><span class=\"token function\">parse</span><span class=\"token punctuation\">(</span>issueBody<span class=\"token punctuation\">,</span> <span class=\"token keyword\">function</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">err<span class=\"token punctuation\">,</span> result</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>err<span class=\"token punctuation\">)</span> <span class=\"token keyword\">throw</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">Error</span><span class=\"token punctuation\">(</span>err<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n      <span class=\"token comment\">// we got the codeblock from the issue</span>\n      <span class=\"token keyword\">let</span> code <span class=\"token operator\">=</span> result<span class=\"token punctuation\">.</span>codes<span class=\"token punctuation\">[</span><span class=\"token number\">0</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">.</span>code<span class=\"token punctuation\">.</span><span class=\"token function\">replace</span><span class=\"token punctuation\">(</span><span class=\"token regex\"><span class=\"token regex-delimiter\">/</span><span class=\"token regex-source language-regex\">\\n,</span><span class=\"token regex-delimiter\">/</span><span class=\"token regex-flags\">gim</span></span><span class=\"token punctuation\">,</span> <span class=\"token string\">''</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n\n      <span class=\"token comment\">// running the codeblock with vm.run()</span>\n      <span class=\"token keyword\">let</span> res <span class=\"token operator\">=</span> vm<span class=\"token punctuation\">.</span><span class=\"token function\">run</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>consoleOverwriteScript<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token string\">\\n</span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>code<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span>\n      \n      console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>res<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n  \n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Almost done! Bare with me.</p>\n<h2 id=\"Creating-Comments\" style=\"position:relative;\"><a href=\"#Creating-Comments\" aria-label=\"Creating Comments permalink\" class=\"gatsby-remark-autolink before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Creating Comments</h2>\n<p>Now lastly, we need to create the comment with octokit's api, and we are all set.</p>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token comment\">// index.js</span>\n\n<span class=\"token comment\">// outside the async function add a new this new function</span>\n<span class=\"token keyword\">async</span> <span class=\"token keyword\">function</span> <span class=\"token function\">createComment</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">msg<span class=\"token punctuation\">,</span> issueNumber</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n  <span class=\"token keyword\">await</span> octokit<span class=\"token punctuation\">.</span>issues<span class=\"token punctuation\">.</span><span class=\"token function\">createComment</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\n    owner<span class=\"token operator\">:</span> <span class=\"token string\">'username'</span><span class=\"token punctuation\">,</span>\n    repo<span class=\"token operator\">:</span> <span class=\"token string\">'my-awesome-repo'</span><span class=\"token punctuation\">,</span>\n    issue_number<span class=\"token operator\">:</span> issueNumber<span class=\"token punctuation\">,</span>\n    body<span class=\"token operator\">:</span> <span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">**Code executed [bot]:**\\n\\n\\`\\`\\`bash\\n</span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span><span class=\"token constant\">JSON</span><span class=\"token punctuation\">.</span><span class=\"token function\">stringify</span><span class=\"token punctuation\">(</span>msg<span class=\"token punctuation\">)</span><span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token string\">\\n\\`\\`\\`</span><span class=\"token template-punctuation string\">`</span></span>\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span>\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p><code class=\"language-text\">createComment</code> function will take the msg (outputted result of the code) and an <em>issueNumber</em> so it can comment on the right issue.</p>\n<p>Let's continue with our code and finish it.</p>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token comment\">// index.js</span>\n\n<span class=\"token comment\">// inside async function</span>\n<span class=\"token operator\">...</span>\n    <span class=\"token comment\">// parse markdown</span>\n    parser<span class=\"token punctuation\">.</span><span class=\"token function\">parse</span><span class=\"token punctuation\">(</span>issueBody<span class=\"token punctuation\">,</span> <span class=\"token keyword\">function</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">err<span class=\"token punctuation\">,</span> result</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\n      <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>err<span class=\"token punctuation\">)</span> <span class=\"token keyword\">throw</span> <span class=\"token keyword\">new</span> <span class=\"token class-name\">Error</span><span class=\"token punctuation\">(</span>err<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token comment\">// vm is acting weirdly when setting console log twice</span>\n      <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>index <span class=\"token operator\">></span> <span class=\"token number\">0</span><span class=\"token punctuation\">)</span> consoleOverwriteScript <span class=\"token operator\">=</span> <span class=\"token string\">''</span><span class=\"token punctuation\">;</span>\n\n      <span class=\"token keyword\">let</span> code <span class=\"token operator\">=</span> result<span class=\"token punctuation\">.</span>codes<span class=\"token punctuation\">[</span><span class=\"token number\">0</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">.</span>code<span class=\"token punctuation\">.</span><span class=\"token function\">replace</span><span class=\"token punctuation\">(</span><span class=\"token regex\"><span class=\"token regex-delimiter\">/</span><span class=\"token regex-source language-regex\">\\n,</span><span class=\"token regex-delimiter\">/</span><span class=\"token regex-flags\">igm</span></span><span class=\"token punctuation\">,</span> <span class=\"token string\">''</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n      <span class=\"token keyword\">let</span> res <span class=\"token operator\">=</span> vm<span class=\"token punctuation\">.</span><span class=\"token function\">run</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>consoleOverwriteScript<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token string\">\\n</span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>code<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span>\n\n      <span class=\"token function\">createComment</span><span class=\"token punctuation\">(</span>res<span class=\"token punctuation\">,</span> issueNumber<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span>\n<span class=\"token operator\">...</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Now you might notice a new variable called <code class=\"language-text\">consoleOverwriteScript</code>, it's kinda weird, and you should not do this in production apps.</p>\n<p>What it does is, it will overwrite the native <code class=\"language-text\">console.log</code> functionality so it can also return the value it logged. see how it looks</p>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token comment\">// index.js</span>\n\n<span class=\"token comment\">// DONT DO THIS</span>\n<span class=\"token keyword\">let</span> consoleOverwriteScript <span class=\"token operator\">=</span> <span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">\nconsole.oldLog = console.log;\nconsole.log = function (value) {\n  console.oldLog(value);\n  return value;\n};\n</span><span class=\"token template-punctuation string\">`</span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>I hope you understand what I'm doing here, and I know it's rather funky.</p>\n<p>Now we are all good to go. If you run <code class=\"language-text\">node index.js</code>, you should see it working locally.</p>\n<h2 id=\"Github-Actions\" style=\"position:relative;\"><a href=\"#Github-Actions\" aria-label=\"Github Actions permalink\" class=\"gatsby-remark-autolink before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Github Actions</h2>\n<p>Setting up Github Actions is relatively simple at this point because we already did everything else.</p>\n<p>So let's jump right into it.</p>\n<p>create a new folder in your root dir called <code class=\"language-text\">.github</code> and inside that create another directory called <code class=\"language-text\">workflows</code></p>\n<p>(just copy-paste this whole yml)</p>\n<div class=\"gatsby-highlight\" data-language=\"yml\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-yml line-numbers\"><code class=\"language-yml\"><span class=\"token comment\"># .github/workflows/code.yml</span>\n\n<span class=\"token comment\"># name of the action</span>\n<span class=\"token key atrule\">name</span><span class=\"token punctuation\">:</span> ExecuteCodeBlock\n\n<span class=\"token comment\"># whenever a new issue is opened, edited, closed run this action</span>\n<span class=\"token key atrule\">on</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">issues</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">types</span><span class=\"token punctuation\">:</span> <span class=\"token punctuation\">[</span>opened<span class=\"token punctuation\">,</span> edited<span class=\"token punctuation\">,</span> deleted<span class=\"token punctuation\">,</span> closed<span class=\"token punctuation\">,</span> reopened<span class=\"token punctuation\">,</span> labeled<span class=\"token punctuation\">,</span> unlabeled<span class=\"token punctuation\">]</span>\n\n<span class=\"token key atrule\">jobs</span><span class=\"token punctuation\">:</span>\n  <span class=\"token key atrule\">build</span><span class=\"token punctuation\">:</span>\n    <span class=\"token key atrule\">runs-on</span><span class=\"token punctuation\">:</span> ubuntu<span class=\"token punctuation\">-</span>latest\n\n    <span class=\"token comment\"># checkout</span>\n    <span class=\"token key atrule\">steps</span><span class=\"token punctuation\">:</span>\n      <span class=\"token punctuation\">-</span> <span class=\"token key atrule\">uses</span><span class=\"token punctuation\">:</span> actions/checkout@v1\n\n      <span class=\"token punctuation\">-</span> <span class=\"token key atrule\">name</span><span class=\"token punctuation\">:</span> setup node\n        <span class=\"token key atrule\">uses</span><span class=\"token punctuation\">:</span> actions/setup<span class=\"token punctuation\">-</span>node@v1\n        <span class=\"token key atrule\">with</span><span class=\"token punctuation\">:</span>\n          <span class=\"token key atrule\">node-version</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"10.x\"</span>\n\n      <span class=\"token comment\"># setup cache</span>\n      <span class=\"token punctuation\">-</span> <span class=\"token key atrule\">name</span><span class=\"token punctuation\">:</span> Cache node modules\n        <span class=\"token key atrule\">uses</span><span class=\"token punctuation\">:</span> actions/cache@v1\n        <span class=\"token key atrule\">with</span><span class=\"token punctuation\">:</span>\n          <span class=\"token key atrule\">path</span><span class=\"token punctuation\">:</span> node_modules\n          <span class=\"token key atrule\">key</span><span class=\"token punctuation\">:</span> $<span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span> runner.os <span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">-</span>node<span class=\"token punctuation\">-</span>$<span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span> hashFiles('<span class=\"token important\">**/package-lock.json')</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span>\n          <span class=\"token key atrule\">restore-keys</span><span class=\"token punctuation\">:</span> <span class=\"token punctuation\">|</span><span class=\"token scalar string\">\n            ${{ runner.os }}-node-</span>\n      \n      <span class=\"token comment\"># run our nodejs code</span>\n      <span class=\"token punctuation\">-</span> <span class=\"token key atrule\">name</span><span class=\"token punctuation\">:</span> Run Code\n        <span class=\"token key atrule\">run</span><span class=\"token punctuation\">:</span> <span class=\"token punctuation\">|</span><span class=\"token scalar string\">\n          npm i\n          node index.js</span>\n        <span class=\"token key atrule\">env</span><span class=\"token punctuation\">:</span>\n          <span class=\"token key atrule\">CI</span><span class=\"token punctuation\">:</span> <span class=\"token boolean important\">true</span>\n          <span class=\"token key atrule\">PERSONAL_TOKEN</span><span class=\"token punctuation\">:</span> $<span class=\"token punctuation\">{</span><span class=\"token punctuation\">{</span> secrets.PERSONAL_TOKEN <span class=\"token punctuation\">}</span><span class=\"token punctuation\">}</span> <span class=\"token comment\"># we already created this PERSONAL_TOKEN</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>YES! We are done, now push everything to GitHub and see the magic happen.</p>\n<p>Whenever a new issue is opened, edited, closed, this action will run and comment down the output of the codeblock.</p>\n<blockquote>\n<p>here are a list of <a href=\"https://help.github.com/en/actions/automating-your-workflow-with-github-actions/events-that-trigger-workflows\">all events that GithubActions supports</a></p>\n</blockquote>\n<p><figure class=\"gatsby-resp-image-figure\" style=\"\">\n    <span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 590px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/ec8c4141f8860dd339e864ba18c05687/c45c7/github-action-running.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 45.94594594594595%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB2UlEQVQoz52Q204TURiF5y00JChSprZTWqYHOm2nQCHe+DI+gO8AFNqqlcR4SPTaeGFMjAlBRWKMx+wbvFJCbQszbefEzLC7/LuJgQSu3MmX/5CVlfVvyXFDmJaPw4GPluFhr2vDMEw4jgPb8eC4HlVX9CfVhev5Yt89NNC3bJi9AXp9CwPLgbTX76DVMdA5MOAI4REwDPG/TzLdNjy7B/jWyYZ7ePDoCWp3mmjcbWKlWsPKWu20EsvVdTE37t1HnTR10lbXG2InPX3XRfNNGxubB3i4bWH1xS7i6SIi16cxISdwaXwSly/iSgTXognSKLg6FcfYhCx20usfJl5+7uDVNxNbP308//ALufISsoUy8qV5KKksosoMogn1HFPxlEAmRnMsmYFEN+IUwO51UZxfQlrTkZ4tYZKSRmJJwdn+n9lZZEWF5PkhH+F4AT8egv/e/8O18iLX9AqfLS3wjKYTZZ7J6zyZ0Til4JSGk+kFpLgUhCGCIMSRH2BICfdbbRTmFkEmqNy4SWcvIK9XoOaKSGULSKg5xKZHJ8+cQ6avIcNjNoIMGRkyMmTaXIWp+SKjVIxEjM4RdTyisGePb7OvO2vs49sq+7LTIOrs0/sa2/2+wVaXb7G/eIrZKrIPC84AAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Github action running (Click to enlarge)\"\n        title=\"Github action running (Click to enlarge)\"\n        src=\"/static/ec8c4141f8860dd339e864ba18c05687/fcda8/github-action-running.png\"\n        srcset=\"/static/ec8c4141f8860dd339e864ba18c05687/12f09/github-action-running.png 148w,\n/static/ec8c4141f8860dd339e864ba18c05687/e4a3f/github-action-running.png 295w,\n/static/ec8c4141f8860dd339e864ba18c05687/fcda8/github-action-running.png 590w,\n/static/ec8c4141f8860dd339e864ba18c05687/efc66/github-action-running.png 885w,\n/static/ec8c4141f8860dd339e864ba18c05687/c83ae/github-action-running.png 1180w,\n/static/ec8c4141f8860dd339e864ba18c05687/c45c7/github-action-running.png 1346w\"\n        sizes=\"(max-width: 590px) 100vw, 590px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n      />\n  </a>\n    </span>\n    <figcaption class=\"gatsby-resp-image-figcaption\">Github action running (Click to enlarge)</figcaption>\n  </figure></p>\n<p>That's all, folks!</p>\n<p>Hopefully, this post was helpful to you, and you learned something about \"Github actions\". Now i encourage you also to create your own Action and have fun with it. Tinker with things and also octokit's API to see what cool stuff you can also make. and if you created anything cool, don't hesitate to <strong>share it with me.</strong></p>\n<hr>\n<p>NOTE: I disabled GitHub action on this repo, so someone cleaver than me doesn't exploit anything.</p>\n<p><strong><a href=\"https://github.com/anuraghazra/GithubActionsPlayground\">See Full Code on GitHub</a></strong></p>\n<p><strong>Useful resources:-</strong></p>\n<ul>\n<li><a href=\"https://octokit.github.io/rest.js/\">Octokit Docs</a></li>\n<li><a href=\"https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line\">Creating A Personal Access Token</a></li>\n<li><a href=\"https://github.com/actions\">Lots Of Actions</a></li>\n<li><a href=\"https://github.blog/2019-08-08-github-actions-now-supports-ci-cd/\">GitHub Actions now supports CI/CD, free for public repositories - Blog</a></li>\n</ul>","timeToRead":7,"id":"468c005c-ab3a-5488-b302-7c71ca142088","frontmatter":{"date":"November 11, 2019","title":"Executing Markdown Codeblocks With Github Actions"}}},"pageContext":{"slug":"/blog/executing-markdown-codeblocks-with-github-actions"}},"staticQueryHashes":["1033876704","3435786681","550521386"]}