Commit Teller - Your personal story teller for your work
Tags: githubhack23, github, quarkus, opensource
Published: 2023-05-21 12:51:12

## What I built 
A new tool has been built that is able to tell a story about your project based on the commit history of your branches, pull requests.

The story can extended along the way and it can be attached to the pull request/issue that is being closed.

### Category Submission: 
Wacky Wildcard

### App Link
https://github.com/rodnansol/commit-teller-action

### Screenshots 

![Pull request before executing the action](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hy1eawr3jfsws42q6cxn.png)

![Successful run](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k711vowh0wl82himr6us.png)

![The steps](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u6a2riwdkfdphem7lxa6.png)


![The result](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9cewh7szqo4j7zfvj56x.png)

Some other example results, the tool was run on older pull requests, and because of that the author of the comments are myself, and not the github-action bot.

Smaller ones:


https://github.com/rodnansol/spring-configuration-property-documenter/pull/53#issuecomment-1557572266
![https://github.com/rodnansol/spring-configuration-property-documenter/pull/53#issuecomment-1557572266](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxa5dmu0z1iz2e4yvg94.png)

https://github.com/rodnansol/spring-configuration-property-documenter/pull/60#issuecomment-1557576442
![https://github.com/rodnansol/spring-configuration-property-documenter/pull/60#issuecomment-1557576442](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4f19s1p2ww60zfj215wg.png)

https://github.com/rodnansol/spring-configuration-property-documenter/pull/45#issuecomment-1557578982
![https://github.com/rodnansol/spring-configuration-property-documenter/pull/45#issuecomment-1557578982](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/stecohivsm84taxpf0q6.png)

And it definitely can do longer ones, in this case the configuration parameters were the following:
```dotenv
COMMIT_TELLER_OPENAI_TEMPERATURE=0.8
COMMIT_TELLER_OPENAI_MAX_TOKEN=2048

COMMIT_TELLER_STORY_TEMPLATE='Write me a story about the following commits. \n
  The story can be only 1536 characters long. \n
  The story should be based on the commit messages, and it should have the following characteristics:'
COMMIT_TELLER_STORY_CHARACTERISTICS='documentation like, funny'
```

https://github.com/rodnansol/spring-configuration-property-documenter/pull/53#issuecomment-1557591882

![https://github.com/rodnansol/spring-configuration-property-documenter/pull/53#issuecomment-1557591882](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1uyy17lvnsci4ucmxaqe.png)







### Description 

The GitHub action utilizes a CLI application that is able to read the commit messages for an given pull request and based on it, it can build a story, that can be descriptive, funny, happy, you name the mood of it. The CLI application uses the GitHub API and of course, the nowadays overhyped OpenAI. It connects to OpenAI via their public API (so an API key is needed) and it will translate your commit messages into a beautiful story.

The CLI application was built with Quarkus, as a Java developer I wanted to use a framework that can help me move fast and I have confidence and fun with that. I definitely did!

### Link to Source Code 

- https://github.com/rodnansol/commit-teller-action
- https://github.com/rodnansol/commit-teller


### Permissive License 
[Apache](https://www.apache.org/licenses/)

## Background (What made you decide to build this particular app? What inspired you?) 

OpenAI's ChatGPT shocked the world (you decide if it happened in a positive or in a negative way for you) and developers, companies are already utilizing their features and enhancing their productivity. There are people who are creating content with that, and I thought... Wait a minute, how about an app that can integrate OpenAI's API and it can summarize me commit messages for pull request. There are million projects out there, and you might not know its story, maybe you want to dig deeper and get to know every small detail of it, so how about a tool that can help your with that?

Don't you like writing documentation? Then write detailed commit messages and use the tool for it! It will not be a full-blown documentation for your API, but if you are just playing with your skills and thoughts this one will help your to have visibility for other people if they are interested in your work.

The characteristics, the OpenAI model and many more can be configured, so you have the ability to have your own story behind your commits :) :tada:

### How I built it (How did you utilize GitHub Actions or GitHub Codespaces? Did you learn something new along the way? Pick up a new skill?) 

As a [Quarkus](https://quarkus.io/) fan, I'm using this Java framework whenever I can, and for CLI apps this is my go to choice. 

#### But why a CLI app?

Because with that I can use it not just in a GitHub action but on my laptop as well, but it definitely gives us wacky questions, why would you like to run it on your laptop? :monocle_face:

First things first, I just made the new Quarkus project, from the template that I have been already setup for CLI applications in my brand new organization called [Rodnan Sol](https://github.com/rodnansol) on GitHub (Do not forget to follow me here :technologist:!)

After the CLI app was ready I made a new repository which contains the setup/configuration for the GitHub action as well.

The setup was easy as the app requires a GitHub token, but GitHub actions always have one implicitly setup for you, but their permission can be changes, this is something I learnt during this time I was making the action setup. This is cool because the token can be narrowed down to the least required list of permissions, so if your action does not have manage repositories you can definitely turn those off, and if they get leaked during the action's lifetime, it could cause no harm to you and your repositories.


### Additional Resources/Info
- A series about the implementation, from the idea to the usage: https://dev.to/nandorholozsnyak/commit-teller-the-beginning-2l5
- Example GitHub repository: https://github.com/rodnansol/commit-teller-example
- GitHub Action itself: https://github.com/rodnansol/commit-teller-action
- The CLI application: https://github.com/rodnansol/commit-teller
- Rodnan Sol GitHub pages: https://rodnansol.github.io/commit-teller/latest/index.html
- Twitter: https://twitter.com/TheRealHNK
- Rodnan Sol Twitter: https://twitter.com/rodnansol