A naive Travis CI job that looks for updates to the languages.yml file in the github/linguist repository.
I built a NodeJS client for GitHub languages (mostly because I'm a huge nerd but also because there's not really a good way to get this information). 1
What are these languages used for?
You can use them for GitHub's Advanced Search, for example (and the associated search API).
However, the client uses an underlying JSON file to power it's API (it's essentially a thin wrapper around a JSON blob).
So when languages get added to the linguist/languages.yml file, the client's underlying JSON file needs to get updated as well.
It's definitely possible to manually
- Fetch the contents of the languages.ymlfile
- Convert to the JSONschema the client expects
- Write JSONtolanguages.jsonfile
- Create a PR if languages.jsonhas changed
- Merge PR, cut a new release of the client, and publish new version to npm
But it's also a pain to remember to do all of these things, especially at least once a day, which is my target cadence (it'd be kind've not great if GitHub added a language to their canonical list of languages, and the client wasn't up-to-date for a week).
So the client actually uses a tool called semantic-release to do all the, well, release automation. So when a PR gets merged (given the correct commit message format) a new GitHub release and npm release will be cut as part of the master Travis CI job.
So I don't need to worry about step 5 (phew!)...but I still need to come up with a plan for steps 1 through 4.
I thought about using Heroku to run this job - and I could definitely see myself moving to Heroku in the future, but I tried implementing the job automation in Travis (Travis has cron jobs!).
In this cron job, I do a
- git clonethe client repository- Set the author information
 
- Create a new branch
- Fetch the contents of languages.yml
- Write JSONtolanguages.jsonfile
- git diffthe file
- If it's changed...
- I git addandgit committhe change with the appropriatesemantic-releasecommit message syntax
- I then create a PR using the octonodelibrary
 
- I 
- If it hasn't changed...do nothing!
- The main scriptfeels kind've gross to me - it just seems a little hacky (I guess I'm just not used to executinggitcommands programmatically).
- The entire implementation is dumb as 💩
- It doesn't take into account existing PRs which might have identical file changes - this might lead to PR pollution
- The reason I made this decision is that I don't expect languages.ymlto change that often
- Also, I keep a pretty close eye on GitHub notifications - I'd hope that if I'm running a daily (at its most frequent) job, I'd be able to merge the automatically generated PR pretty quickly.
 
- The reason I made this decision is that I don't expect 
 
- It doesn't take into account existing PRs which might have identical file changes - this might lead to PR pollution