A GitHub action to trigger an alarm on your room 🚨
Tags: actionshackathon, iot, adafruit
Published: 2020-09-11 04:05:41

### My journey on the actions hackathon

I'm submitting this post as part of my [Actions Hackathon](https://dev.to/devteam/announcing-the-github-actions-hackathon-on-dev-3ljn) journey and also my participation.

Action in action:
{% youtube Pji4cxY6PXA %}

### Motivation

I always imagined open-source mantainers as heroes, since they spend lots of their free time just to share their knowledge with useful software and give back to the oss community, many times I've meet people who are passionate about OSS and for me they deserve the best.

So I'm making a simple action (my first one tho!) that is able to trigger an alarm on your room when someone opens up an Issue on your configured repositories, now you can feel like a hero when the city needs you! You may also remix this action to turn on a Batman signal on the ceiling of your room 🦸 🦇 (It's a great idea!)

![Issuetron box](https://dev-to-uploads.s3.amazonaws.com/i/3j9i0sr1kmdshsuwkggg.jpg)
*I know is not pretty, but it serves it's purpose 👻*

### Submission Category:

Interesting IoT

### Yaml File or Link to Code

```yaml
on:
  issues:
    types: [opened]

jobs:
  do_iot_thing:
    runs-on: ubuntu-latest
    name: A job to turn on a light when someone opens an issue
    steps:
      - name: Send activation to ESP8266 device
        uses: 'mxarc/issuetron-3000@1.1'
        id: activation
        with:
          time: '15' # how much time we will keep our light on
          blink: true # enable blinking, otherwise just turn on the lamp
          io_user: '${{ secrets.IO_USER }}'
          io_key: '${{ secrets.IO_KEY }}'
          io_feed: 'issuetron'
          send_context: true
      # Use the output from the `hello` step
      - name: Check if we succeeded to turn on the light
        run: echo "The result of the action is ${{ steps.activation.outputs.success }}"
```

Link to the Action in marketplace:
https://github.com/marketplace/actions/issuetron-3000

#### Source code

{% github mxarc/issuetron-3000 %}


### How I'm making this

🔧 I'm using Adafruit IO cloud for the ease of IoT development and device provisioning, since I know most people would like to configure a device the _easy_ way and not have to go through complicated setups like AWS or Azure IoT.

The Action workflow is listening to an "Issue" event and when it's triggered it gets the issue context (like username and issue title) and sends the content over MQTT protocol to an ESP8266 device which I had lying around, it turns on a red lamp which I got from a auto parts store. 🚨

Action is able to send context about the issue, being those details:
* issue title
* issue author
* repo of origin

You can also disable the issue context if you want to save some bytes or you only want to trigger a custom action on your IoT device.

This action leverages repo secrets, since some variables like the device Key and ID are supposed to be secret, you can find more information on the README on how to setup your device.

![Wiring](https://dev-to-uploads.s3.amazonaws.com/i/8g5pc8o4y4uic8xe8sb9.png)
**Example of how to wire your IoT device**

In the above image we have a red LED, but I suggest you use another source of light or maybe add a ring bell!

You can see the action in action here:
 {% twitter 1295848520990302209 %}

### What I have learned creating this action

I was able to understand the basics of GitHub actions, the hackathon was the perfect motivation to begin learning more about this wonderful tool, I plan to make more IoT related projects in the future that use GitHub actions in one way or another.

The GitHub actions documentation it's the best place to start, don't be afraid to follow it, it covers everything from creating a starter project to deploying your first action.