DEV Community

Michal Moczulski
Michal Moczulski

Posted on

3 2

πŸ”Š Say Github - monitoring Github Workflow

Introduction

Disclaimer: Presented solution applies to OS X but the general idea can be easily adjusted to other systems.

Recently I have found a great tool called saydle. It's a simple Gradle wrapper that notifies you using say command when your build is completed.

I think it's a great example of improving everyday workflow with simple system command. I run many Android builds on daily basis using Github CI, so I've started thinking about similar solution for notifying me when my Github Workflow is completed.

Solution - 1st approach

After doing quick research, it turned out that I've already had all the necessary components to monitor Github Workflow.

I used Github command line tool to be notified when a workflow is completed.

gh run watch <run-id> && say "Workflow completed"
Enter fullscreen mode Exit fullscreen mode

Run id can be obtained directly from the workflow URL or the workflow list command

gh run list
Enter fullscreen mode Exit fullscreen mode

System notification - 2nd approach

Going a step further I've thought that relying on sound maybe it's not the best option. I've decided to display system notification instead of using say command. For displaying notification I used terminal-notifier tool which is pretty straightforward to use.

gh run watch <run-id> && terminal-notifier -message 'Workflow completed'
Enter fullscreen mode Exit fullscreen mode

Clickable notification - my final approach

At this moment I was pretty happy with my current solution but then I thought that clickable notification taking me directly to the Github Workflow result page would be even cooler.

After checking that terminal-notifier supports URL parameter I created a simple script.

#!/usr/bin/env bash

WORKFLOW_ID=$1
URL=https://github.com/<USERNAME>/<PROJECT>/actions/runs/$WORKFLOW_ID
gh run watch $WORKFLOW_ID && terminal-notifier -message 'Workflow completed' -open $URL
Enter fullscreen mode Exit fullscreen mode

Usage is simple:

./monitor-workflow <run-id>
Enter fullscreen mode Exit fullscreen mode

After my workflow was completed I've got the notification:

System notification

And as expected, clicking it took me to the result page.

Summary

It took me around 20 minutes to build the final version. It helps me save time every day while I'm waiting for my Android builds.

Maybe this solution won't fit your needs, but I want to encourage you to create tools that work for you. Creating custom solutions with all the great tools out there is now simpler than ever before.

Happy hacking :)

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly β€” using the tools and languages you already love!

Learn More

Top comments (0)

Quickstart image

Django MongoDB Backend Quickstart! A Step-by-Step Tutorial

Get up and running with the new Django MongoDB Backend Python library! This tutorial covers creating a Django application, connecting it to MongoDB Atlas, performing CRUD operations, and configuring the Django admin for MongoDB.

Watch full video β†’

πŸ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay