<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Frooth</title>
    <description>The latest articles on Forem by Frooth (@frasertooth).</description>
    <link>https://forem.com/frasertooth</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F453853%2F47a68b88-de3d-4c90-b027-136d8779e623.jpg</url>
      <title>Forem: Frooth</title>
      <link>https://forem.com/frasertooth</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/frasertooth"/>
    <language>en</language>
    <item>
      <title>Go To Sleep-a-tron Github Actions Hackathon Submission</title>
      <dc:creator>Frooth</dc:creator>
      <pubDate>Sun, 23 Aug 2020 16:10:54 +0000</pubDate>
      <link>https://forem.com/frasertooth/go-to-sleep-a-tron-1cmk</link>
      <guid>https://forem.com/frasertooth/go-to-sleep-a-tron-1cmk</guid>
      <description>&lt;h3&gt;
  
  
  My Workflow
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Name:&lt;/strong&gt; FraserTooth/go-to-sleep&lt;br&gt;
&lt;strong&gt;Description:&lt;/strong&gt; This Github Action will use the timestamps in commit logs to figure out whether someone is doing work past their bed time...and tell them off!&lt;br&gt;
&lt;strong&gt;Being Used:&lt;/strong&gt; On itself...🤣&lt;br&gt;
&lt;strong&gt;Github:&lt;/strong&gt; &lt;a href="https://github.com/FraserTooth/go-to-sleep"&gt;Link&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Submission Category:
&lt;/h3&gt;

&lt;p&gt;Wacky Wildcards (I think...)&lt;/p&gt;

&lt;h3&gt;
  
  
  Yaml File or Link to Code
&lt;/h3&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/FraserTooth"&gt;
        FraserTooth
      &lt;/a&gt; / &lt;a href="https://github.com/FraserTooth/go-to-sleep"&gt;
        go-to-sleep
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Stop coding and go to sleep!
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
The Github Go-To-Sleep-a-Tron Action&lt;/h1&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://camo.githubusercontent.com/1ab050b3b1248e273b30fc91ffcaf9a80af8299c/68747470733a2f2f6d656469612e67697068792e636f6d2f6d656469612f6d67755072564a416e454849592f67697068792e676966"&gt;&lt;img src="https://camo.githubusercontent.com/1ab050b3b1248e273b30fc91ffcaf9a80af8299c/68747470733a2f2f6d656469612e67697068792e636f6d2f6d656469612f6d67755072564a416e454849592f67697068792e676966" alt="Sleepy Time"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stop coding and go to sleep!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(Example Commit with Message)[&lt;a href="https://github.com/FraserTooth/go-to-sleep-action/commit/a46d6fd23defa2b5b9c974cebbc843eeb01a5ff9"&gt;https://github.com/FraserTooth/go-to-sleep-action/commit/a46d6fd23defa2b5b9c974cebbc843eeb01a5ff9&lt;/a&gt;]&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
Inputs&lt;/h2&gt;

&lt;h3&gt;
&lt;code&gt;GITHUB_TOKEN&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Required&lt;/strong&gt;&lt;br&gt;
Just put &lt;code&gt;${{ secrets.GITHUB_TOKEN }}&lt;/code&gt; and it should work fine.&lt;/p&gt;

&lt;h3&gt;
&lt;code&gt;custom_mesage&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Optional&lt;/strong&gt;&lt;br&gt;
Put your custom message as a HTML formatted string:&lt;br&gt;
e.g. &lt;code&gt;custom_message: "Oh dear, its very late where you are.\nWe appreciate your hard work but maybe you should go to bed."&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Default: &lt;code&gt;"Its quite late, maybe you should go to sleep!"&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
&lt;code&gt;timezone&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Required for any events other than commits (push)&lt;/strong&gt;&lt;br&gt;
Enter your team's timezone in the ISO format &lt;code&gt;(+/-)hh:mm&lt;/code&gt;:&lt;br&gt;
e.g. &lt;code&gt;timezone: "+09:00"&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
How to use&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;If you do not have any Github actions already set up in your repo, start by creating a .github/workflows folder.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Inside your workflows folder, create a new .yml file, for example &lt;code&gt;main.yml&lt;/code&gt; and copy the following lines:&lt;/p&gt;

&lt;div class="highlight highlight-source-yaml"&gt;
&lt;pre&gt;&lt;span class="pl-ent"&gt;on&lt;/span&gt;
  &lt;span class="pl-s"&gt;[&lt;/span&gt;
    &lt;span class="pl-s"&gt;push,&lt;/span&gt;
    &lt;span class="pl-s"&gt;pull_request,                 &lt;/span&gt;&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Slightly Supported&lt;/span&gt;
    &lt;span class="pl-s"&gt;pull_request_review,          &lt;/span&gt;&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Not Supported&lt;/span&gt;
    &lt;span class="pl-s"&gt;pull_request_review_comment,  &lt;/span&gt;&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Not Supported&lt;/span&gt;
    &lt;span class="pl-s"&gt;issues,                       &lt;/span&gt;&lt;/pre&gt;…&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/FraserTooth/go-to-sleep"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/FraserTooth/go-to-sleep/releases/tag/1"&gt;Link to Release&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Additional Resources / Info
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://dev.to/frasertooth/combatting-burnout-with-the-go-to-sleep-a-tron-25f9"&gt;Explanatory DEV.to Post&lt;/a&gt;&lt;/p&gt;

</description>
      <category>actionshackathon</category>
    </item>
    <item>
      <title>Combatting Burnout with the "Go to Sleep-a-tron"</title>
      <dc:creator>Frooth</dc:creator>
      <pubDate>Sun, 23 Aug 2020 16:08:50 +0000</pubDate>
      <link>https://forem.com/frasertooth/combatting-burnout-with-the-go-to-sleep-a-tron-25f9</link>
      <guid>https://forem.com/frasertooth/combatting-burnout-with-the-go-to-sleep-a-tron-25f9</guid>
      <description>&lt;p&gt;A couple of weeks ago, I saw two things:&lt;/p&gt;

&lt;p&gt;First, I saw a tweet from Charlie Gerard showing her great project to combine ML and Github culture to create a Github action to auto-admonish toxic comments on PRs and the like.&lt;br&gt;
 &lt;iframe class="tweet-embed" id="tweet-1295096920168452099-776" src="https://platform.twitter.com/embed/Tweet.html?id=1295096920168452099"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1295096920168452099-776');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1295096920168452099&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;Then I saw the &lt;a href="https://dev.to/devteam/announcing-the-github-actions-hackathon-on-dev-3ljn"&gt;Actions Hackathon&lt;/a&gt; challenge announced and thought I should give it a go.&lt;/p&gt;

&lt;p&gt;So, inspired by Charlie's idea of making Github culture a little better (and no small amount of using her code-base to figure out Github Actions), I hereby present my very silly Github Action &lt;a href="https://github.com/FraserTooth/go-to-sleep" rel="noopener noreferrer"&gt;go-to-sleep&lt;/a&gt; aka &lt;strong&gt;The Go-To-Sleep-a-tron&lt;/strong&gt; &lt;em&gt;&lt;a href="https://dev.to/frasertooth/go-to-sleep-a-tron-1cmk"&gt;Hackathon Submission&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/FraserTooth" rel="noopener noreferrer"&gt;
        FraserTooth
      &lt;/a&gt; / &lt;a href="https://github.com/FraserTooth/go-to-sleep" rel="noopener noreferrer"&gt;
        go-to-sleep
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Stop coding and go to sleep!
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;The Github Go-To-Sleep-a-Tron Action&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer nofollow" href="https://camo.githubusercontent.com/e275cc8148597c6b81c8992a96a6b7d0ffdcaac033a441d954e3c549292c3e1e/68747470733a2f2f6d656469612e67697068792e636f6d2f6d656469612f6d67755072564a416e454849592f67697068792e676966"&gt;&lt;img src="https://camo.githubusercontent.com/e275cc8148597c6b81c8992a96a6b7d0ffdcaac033a441d954e3c549292c3e1e/68747470733a2f2f6d656469612e67697068792e636f6d2f6d656469612f6d67755072564a416e454849592f67697068792e676966" alt="Sleepy Time"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Stop coding and go to sleep!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/FraserTooth/go-to-sleep-action/commit/a46d6fd23defa2b5b9c974cebbc843eeb01a5ff9" rel="noopener noreferrer"&gt;Example Commit with Message&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Inputs&lt;/h2&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;&lt;code&gt;GITHUB_TOKEN&lt;/code&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Required&lt;/strong&gt;&lt;br&gt;
Just put &lt;code&gt;${{ secrets.GITHUB_TOKEN }}&lt;/code&gt; and it should work fine.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;&lt;code&gt;custom_mesage&lt;/code&gt;&lt;/h3&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Optional&lt;/strong&gt;&lt;br&gt;
Put your custom message as a HTML formatted string:&lt;br&gt;
e.g. &lt;code&gt;custom_message: "Oh dear, its very late where you are.\nWe appreciate your hard work but maybe you should go to bed."&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Default: &lt;code&gt;"Its quite late, maybe you should go to sleep!"&lt;/code&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;&lt;code&gt;timezone&lt;/code&gt;&lt;/h3&gt;

&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Required for any events other than commits (push)&lt;/strong&gt;&lt;br&gt;
Enter your team's timezone in the ISO format &lt;code&gt;(+/-)hh:mm&lt;/code&gt;:&lt;br&gt;
e.g. &lt;code&gt;timezone: "+09:00"&lt;/code&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;How to use&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;&lt;em&gt;If you do not have any Github actions already set up in your repo, start by creating a .github/workflows folder.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Inside your workflows folder, create a new .yml file, for example &lt;code&gt;main.yml&lt;/code&gt; and copy the following lines:&lt;/p&gt;
&lt;div class="highlight highlight-source-yaml notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-ent"&gt;on&lt;/span&gt;
  &lt;span class="pl-s"&gt;[&lt;/span&gt;
    &lt;span class="pl-s"&gt;push,&lt;/span&gt;
    &lt;span class="pl-s"&gt;pull_request,                 &lt;/span&gt;&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Slightly Supported&lt;/span&gt;
    &lt;span class="pl-s"&gt;pull_request_review,          &lt;/span&gt;&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Not Supported&lt;/span&gt;
    &lt;span class="pl-s"&gt;pull_request_review_comment,  &lt;/span&gt;&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Not Supported&lt;/span&gt;
    &lt;span class="pl-s"&gt;issues,                       &lt;/span&gt;&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; Not&lt;/span&gt;&lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/FraserTooth/go-to-sleep" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;In short, this Action will simply check the time of the commits pushed to the repo, and will post a comment to the commit if it was committed 'overnight', from the perspective of the committer's timezone. It will work on any branch and the message you send can be customised 😁&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyl3kx9zh9t1n8bvj59z0.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fyl3kx9zh9t1n8bvj59z0.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've currently set it to trigger before 9am and after 7pm, because thats when you should be cooking, eating, sleeping and reading terrible dev.to articles instead of doing more work!&lt;/p&gt;

&lt;p&gt;My intended user would be companies who want to discourage overworking, so if you want me to keep working on this, &lt;a href="https://github.com/FraserTooth/go-to-sleep-action/issues" rel="noopener noreferrer"&gt;let me know!&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;For the most part I followed the &lt;a href="https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action" rel="noopener noreferrer"&gt;Official Guides&lt;/a&gt; and &lt;a href="https://github.com/charliegerard/safe-space" rel="noopener noreferrer"&gt;Charlie's Code&lt;/a&gt; but in general my code does the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Takes in the Action Data and Inputs&lt;/li&gt;
&lt;li&gt;If its a Commit Action ('Push') it will check each commit for a &lt;code&gt;timestamp&lt;/code&gt; field. Which contains the time, and thankfully, the timezone in which the commit was made.&lt;/li&gt;
&lt;li&gt;If the time is before 9am or after 7pm in a given day, a comment will be posted on the commit, using the custom or default message.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Pretty simple right, but there were some gotchas...&lt;/p&gt;

&lt;h2&gt;
  
  
  The Gotchas
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Timestamps in Github
&lt;/h3&gt;

&lt;p&gt;I initially wanted to have this trigger for any commentable Github action (Open PR, PR Review, Issues...) but for some reason, the &lt;strong&gt;only&lt;/strong&gt; timestamp within the data provided both within the Github actions data and the Github API that contains the commiter's timezone is "commit data" inside Github Actions input data. Otherwise, the time is only available in UTC 🤷‍♀️ (you can check my &lt;a href="https://github.com/FraserTooth/go-to-sleep-action/tree/master/test/fixtures" rel="noopener noreferrer"&gt;test data&lt;/a&gt; for examples of the data given)&lt;br&gt;
Naturally, the next step is to allow the addition of user-specific timezones as an input to the &lt;code&gt;workflows/main.yml&lt;/code&gt; file, but this removed some of the magic and wasn't as fun 😔&lt;/p&gt;

&lt;h3&gt;
  
  
  Timezones in Javascript
&lt;/h3&gt;

&lt;p&gt;Timezones are a known pain point in programming, and yes, there are some good libraries like &lt;a href="https://momentjs.com/" rel="noopener noreferrer"&gt;moment.js&lt;/a&gt; to help with this...in a normal situation.&lt;br&gt;
The issue I had, was that these timezone libraries are built with the understanding that you will know where the person is before you need to make the conversion, such as the country.&lt;br&gt;
As far as I can tell, it's not possible to find out the location of a given Github user (profile location is too 'custom' and I found no usable data in the API), and plus...I didn't really need to care 😂. I &lt;strong&gt;already had the timezone&lt;/strong&gt;, so I could just figure out if they were up late, regardless of their actual location.&lt;br&gt;
However, there isn't an easy way to retain 'original timezone' when parsing dates with these libraries, so upon parsing the datestring, I would be stuck in UTC 😒&lt;br&gt;
In the end, I just ended up using Regex to extract the timezone section of the string and do the 'is it bedtime' math manually. It was kind of painful, but I suppose I learnt something about dates in Javascript 😵...or something...&lt;/p&gt;

&lt;h3&gt;
  
  
  Github Actions Dev Cycle
&lt;/h3&gt;

&lt;p&gt;Another gotcha was that its kinda annoying to get Github actions running locally, so in developing this I was stuck making commits and pushes to check the functionality...&lt;br&gt;
There is a rather neat tool called &lt;a href="https://github.com/nektos/act" rel="noopener noreferrer"&gt;act&lt;/a&gt; which allows you to run Github actions locally 🙌 but I could only figure out how to get them from a remote source, so I just had to push the changes to Github anyway 😐&lt;br&gt;
While writing this, I found an &lt;a href="https://github.com/nektos/act/issues/307" rel="noopener noreferrer"&gt;Issue&lt;/a&gt; in the repo that suggests getting local actions is doable, so that would be my next TODO.&lt;/p&gt;

&lt;h2&gt;
  
  
  Future Feature Ideas
&lt;/h2&gt;

&lt;p&gt;Aside from some small obvious things, if people think this idea is interesting (and encourage me to improve it!), I think these additions might be useful:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add more Github Action types (despite the lack of magic)

&lt;ul&gt;
&lt;li&gt;There might be a clever way to figure out a commenter/contributer's timezone, but short of keeping a database I'm not sure what it would be outside of...&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Add a 'per Github contributor' timezone

&lt;ul&gt;
&lt;li&gt;This would solve problem one, but it strikes me as clunky 🤔&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Allow configuration of posting to a basic Slack webhook or sending an Email to send notifications outside of Github

&lt;ul&gt;
&lt;li&gt;One key problem with this is that I never read emails from Github or look at the notifications 🤣, sending messages externally might be useful for a Manager to keep an eye out for unhealthy behaviour.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Cheers M'Dears
&lt;/h2&gt;

&lt;p&gt;All in all, thank you for reading, check out my &lt;a href="https://github.com/FraserTooth" rel="noopener noreferrer"&gt;Github&lt;/a&gt; for other projects and my &lt;a href="https://twitter.com/FraserTooth" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; for inconsistent mutterings. Cheerio!&lt;/p&gt;

</description>
      <category>actionshackathon</category>
      <category>github</category>
      <category>javascript</category>
      <category>burnout</category>
    </item>
  </channel>
</rss>
