DEV Community

Cover image for Show off your DevOps efforts on GitHub
Anton Sizikov
Anton Sizikov

Posted on

Show off your DevOps efforts on GitHub

In the era of DevOps some of us write yaml-files on a daily basis. Sometimes it's just a lot of yamls. I would say that in some repositories YAML is more than just 'a data-file', it's a valuable artifact where the core (or just important) logic resides.

However GitHub doesn't think so. You know that there is a Language Breakdown Graph on every GitHub repository:

Alt Text

It looks cool, it highlights the languages used in this repo.
However, your DevOps efforts are not represented on this chart. No Kubernetes or Docker-Compose manifests and Charts, no CI/CD pipelines, no GitHub Actions, and other sometimes tricky configurations.

Luckily this is something we can fix.

GitHub Linguist

GitHub uses a library called Linguist (https://github.com/github/linguist) to analyze your repository. Of course, the Language Breakdown Graph is more of a side-effect and definitely not the main purpose of this analysis. But for now we'll focus on this particular feature of Linguist.

All languages known to Linguist can be found in the languages.yml file in the linguist repository.

Let's check YAML definition

YAML:
  type: data
  color: "#cb171e"
  tm_scope: source.yaml
Enter fullscreen mode Exit fullscreen mode

as you can see, it's treated as a data file by default and thus it's left out from the graph.

Overriding Linguist behavior

We can add (or edit existing) .gitattributes file with the following content to the root of our repository:

*.yml linguist-detectable=true
*.yml linguist-language=YAML
*.yaml linguist-detectable=true
*.yaml linguist-language=YAML
Enter fullscreen mode Exit fullscreen mode

and Linguist will respect that override, by showing us a proper Language Breakdown on your page:

Alt Text

Isn't it cool?

There is more

It's not just the way YAML files are treated. You can fine-tune that to emphasize the work which is important in your opinion.

Do you have a repository full of Markdown files, perhaps a book that you're writing? Well, Markdown can be marked as linguist-detectable as well.

Do you have some samples or generated files that you want to exclude? linguist-generated and linguist-documentation attributes can be used.

You can go wild and mess up with it:

# Example of a `.gitattributes` file 
# which reclassifies `.rb` files as Java:
*.rb linguist-language=Java
Enter fullscreen mode Exit fullscreen mode

Additional documentation and examples can be found here.

Call to Action

I hope you enjoyed this little trick. Now go and celebrate your DevOps work by including it in your repository stats.

Top comments (0)