<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Automation on foosel.net</title><link>https://foosel.net/tags/automation/</link><description>Recent content in Automation on foosel.net</description><generator>Hugo</generator><language>en-us</language><copyright>Gina Häußge (foosel)</copyright><lastBuildDate>Thu, 16 Jun 2022 00:00:00 +0000</lastBuildDate><atom:link href="https://foosel.net/tags/automation/index.xml" rel="self" type="application/rss+xml"/><item><title>How to sync starred GitHub repos to Raindrop via NodeRED</title><link>https://foosel.net/til/how-to-sync-starred-github-repos-to-raindrop-via-nodered/</link><pubDate>Thu, 16 Jun 2022 00:00:00 +0000</pubDate><guid>https://foosel.net/til/how-to-sync-starred-github-repos-to-raindrop-via-nodered/</guid><description>&lt;p&gt;The following flow syncs starred repos of a GitHub user to Raindrop.io every 10min and on trigger:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Screenshot of a NodeRED flow. Two nodes &amp;ldquo;every 10min&amp;rdquo; and &amp;ldquo;timestamp&amp;rdquo; lead to a node &amp;ldquo;Starred repos for foosel&amp;rdquo;. That is wired to &amp;ldquo;Preprocess&amp;rdquo; which in turn is wired to &amp;ldquo;Save in Raindrop.io&amp;rdquo;" loading="lazy" src="https://foosel.net/til/how-to-sync-starred-github-repos-to-raindrop-via-nodered/nodered.png"&gt;&lt;/p&gt;
&lt;p&gt;&amp;ldquo;Every 10min&amp;rdquo; is a cron trigger node that fires every 10min. &amp;ldquo;timestamp&amp;rdquo; is an inject node for triggering the flow manually.&lt;/p&gt;</description><content:encoded><![CDATA[<p>The following flow syncs starred repos of a GitHub user to Raindrop.io every 10min and on trigger:</p>
<p><img alt="Screenshot of a NodeRED flow. Two nodes &ldquo;every 10min&rdquo; and &ldquo;timestamp&rdquo; lead to a node &ldquo;Starred repos for foosel&rdquo;. That is wired to &ldquo;Preprocess&rdquo; which in turn is wired to &ldquo;Save in Raindrop.io&rdquo;" loading="lazy" src="/til/how-to-sync-starred-github-repos-to-raindrop-via-nodered/nodered.png"></p>
<p>&ldquo;Every 10min&rdquo; is a cron trigger node that fires every 10min. &ldquo;timestamp&rdquo; is an inject node for triggering the flow manually.</p>
<p>&ldquo;Starred repos for foosel&rdquo; is an HTTP GET request against <code>https://api.github.com/users/foosel/starred</code>, set to return an object parsed from the response JSON. Change <code>foosel</code> to your own username.</p>
<p>The &ldquo;Preprocess&rdquo; function node has this source:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-js" data-lang="js"><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">key</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;feed_githubstars_repos&#34;</span>;
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">repos</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">flow</span>.<span style="color:#a6e22e">get</span>(<span style="color:#a6e22e">key</span>) <span style="color:#f92672">||</span> [];
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">added</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">msg</span>.<span style="color:#a6e22e">payload</span>.<span style="color:#a6e22e">filter</span>(<span style="color:#a6e22e">repo</span> =&gt; <span style="color:#f92672">!</span><span style="color:#a6e22e">repos</span>.<span style="color:#a6e22e">includes</span>(<span style="color:#a6e22e">repo</span>.<span style="color:#a6e22e">full_name</span>));
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">flow</span>.<span style="color:#a6e22e">set</span>(<span style="color:#a6e22e">key</span>, <span style="color:#a6e22e">repos</span>.<span style="color:#a6e22e">concat</span>(<span style="color:#a6e22e">added</span>.<span style="color:#a6e22e">map</span>(<span style="color:#a6e22e">repo</span> =&gt; <span style="color:#a6e22e">repo</span>.<span style="color:#a6e22e">full_name</span>)));
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">return</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">payload</span><span style="color:#f92672">:</span> {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">items</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">added</span>.<span style="color:#a6e22e">map</span>(<span style="color:#a6e22e">repo</span> =&gt; {
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">return</span> {
</span></span><span style="display:flex;"><span>                <span style="color:#a6e22e">title</span><span style="color:#f92672">:</span> <span style="color:#e6db74">`</span><span style="color:#e6db74">${</span><span style="color:#a6e22e">repo</span>.<span style="color:#a6e22e">full_name</span><span style="color:#e6db74">}</span><span style="color:#e6db74">: </span><span style="color:#e6db74">${</span><span style="color:#a6e22e">repo</span>.<span style="color:#a6e22e">description</span><span style="color:#e6db74">}</span><span style="color:#e6db74">`</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#a6e22e">link</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">repo</span>.<span style="color:#a6e22e">html_url</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#a6e22e">tags</span><span style="color:#f92672">:</span> [<span style="color:#e6db74">&#34;github&#34;</span>, <span style="color:#e6db74">&#34;starred&#34;</span>]
</span></span><span style="display:flex;"><span>            }
</span></span><span style="display:flex;"><span>        })
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>&ldquo;Save in Raindrop.io&rdquo; performs an HTTP POST request against <code>https://api.raindrop.io/rest/v1/raindrops</code> with authentication type&quot;Bearer&quot; and an API token created <a href="https://app.raindrop.io/settings/integrations">here</a>.</p>
]]></content:encoded></item></channel></rss>