This is probably the most overengineered thing I ever did.

This is probably the most overengineered thing I ever did.

For those who don't know, since July of 2020, you can create a repository on GitHub with your tag as name. After that, the of this repository is shown on your profile.

Pretty cool, right?

Well, as you can see, in the first sentence, I give some corner information about me like my name, country I live in as well as my age.
As you might have spotted already, there is a huge problem: I would need to update my age every single year on my birthday, which is absolutely non-acceptable.

Well, to dodge this, I had a smart idea. I had the following sentence as introduction with a funny little joke for my age.

But people actually asked me, if this "is right" or if there is "something buggy" and did not get the joke.

So, I needed a better solution. Automation.

So, I've written this handy dandy python script, which looks for "replacers" in the readme, executes them and replaces them with the new result.

A "replacer" is a comment in the which holds a function as well as an optional argument. The string directly after the "replacer" comment is the target to be replaced.

The script is using the following regular expression to find and parse all replacers.

Then, the match groups are passed to a Replacer class constructor which defines the  function and argument as well as the original string to find it later to replace it with the new result.

As you can see, functions are currently hard-coded into the replacer class. Also, there is only a single on called age. It simply takes a date as argument and calculates the years until today, which then are returned as result.

Now, some GitHub Action magic comes into place. The following workflow pipeline is scheduled do be executed every 12th of December each year to execute the script. The replaced result is written back into the After that, the changes are committed and pushed into the repository.

Isn't that  amazing? Now I do not need to worry about updating my date in my profile readme ever again. And because my script is so modular, I could even add a year counter for stuff like the years since I've started coding or something like that.

Well, setting up this stuff took me a good hour, but it saves me a whole minute it would take every year to update the age in the readme. So, it pays out after only 60 years, yay!

If you are interested in the source files and stuff, don't be shy to pass by. 😉

My Profile Readme. Contribute to zekroTJA/zekroTJA development by creating an account on GitHub.