DEV Community

Julien Lengrand-Lambert
Julien Lengrand-Lambert

Posted on • Originally published at lengrand.fr on

Automatically add the Hacktoberfest tag to all of your GitHub repositories

Automatically add the Hacktoberfest tag to all of your GitHub repositories

TL;DR : Clone this, change the input variables and run

I'm sure you know it already, it's #hacktoberfest season!

We're welcoming pull requests at Adyen, and we have quite a few repositories. So as any engineer would do, I spent an hour automating something I could have done in 10 minutes! Here is a small utility that finds all the repositories you are an owner of, and add the Hacktoberfest topic to them :).

I really like Kotlin, and today was the Kotlin Premiere event (lots of good stuff announced btw, have a look!) so that's the language I decided to go for. Instead of using the Java GitHub API, I went barebones with a Ktor client and the default kotlinx serialization.

You can find the complete code here, it's not super complicated :). Here it is, in all of its glory :

Automatically add the Hacktoberfest tag to all of your GitHub repositories

A few things I learnt tonight :

  • It is quite easy to remap the JSON payload of the requests when deserializing using the @SerialName annotation.
  • Don't forget to use the ignoreUnknownKeys if you go for minimal interfaces, at the risk of spending some time searching why your deserialization fails.
  • Using enums as strings is quite seemless, no need for the toString methods. Nice!
  • Also nice to see that you can easily add elements to immutable list (well, return a new immutable list with the new element added) simply using the + operator. I tried it, coming from Elm and BOUM it worked!

That's it! There isn't much more to say :). I know it can be improved and there is some slight duplication but for its use that's definitely good enough. If I'm motivated enough, I might try to see if I can make it multi-platform, that'd be fun!

Till next time!

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay