-1

I'd like to link to GitHub milestones by their name. We have milestones named by version numbers, e.g. 0.1.0, 0.1.1, 0.2.0... but milestones URLs have internal numbers (https://github.com/owner/project/milestone/1, https://github.com/owner/project/milestone/2, ...). How can I automatically generate a link to the corresponding milestone URL given only its milestone name?

Jakob
  • 3,570
  • 3
  • 36
  • 49
  • `[whatever you want](actual link)`? – jonrsharpe Jun 25 '19 at 07:20
  • @jonrsharpe I clarified my question: the actual links should be *generated automatically* based on the milestone name. – Jakob Jun 25 '19 at 08:44
  • The auto linking on GitHub is described [here](https://help.github.com/en/articles/autolinked-references-and-urls). Milestones aren't covered. – jonrsharpe Jun 25 '19 at 08:47
  • @jonrsharpe my question is not limited to links in GitHub Markdown syntax. If neither GitHub nor third-party services provide such linking capability, it's probably possibly by using the GitHub API – Jakob Jun 25 '19 at 20:55
  • So what is the scope? Have you tried using the API? What happened? – jonrsharpe Jun 25 '19 at 20:56
  • I have not tried the API but I would accept a detailled answer that explains how to use the API for this use case. I asked because I hoped there was another method such as a special kind of URL template provided by GitHub or by another service. – Jakob Jun 26 '19 at 05:08

1 Answers1

0

There seems to be no official way or third-party service to link to a GitHub milestone by its name but it would be easy to build such service based on GitHub API. As indicated by jonrsharpe, the milestones API can be used to query all milestones and then find a corresponding link. Given user $USER, repository name $REPO and milestone name $VERSION, this one-line gets the milestone URL (requires curl and jq):

curl -s 'https://api.github.com/repos/$USER/$REPO/milestones?per_page=100' \
  | jq -r ".[]|select(.title==\"$VERSION\").html_url"

This only works for up to 100 milestones because of API response pagination.

Jakob
  • 3,570
  • 3
  • 36
  • 49