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?
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.