Skip to content

Instantly share code, notes, and snippets.

@shanonvl
Last active June 26, 2017 14:35
Show Gist options
  • Save shanonvl/11744f444fb125ff5321d41f1a8556c8 to your computer and use it in GitHub Desktop.
Save shanonvl/11744f444fb125ff5321d41f1a8556c8 to your computer and use it in GitHub Desktop.
Cheat Sheets

GitHub API Cheat Sheet

Setup

  • Identify/acquire a valid GitHub Personal Access Token (PAT)
  • Set GITHUB_USER and GITHUB_API_TOKEN e.g. via the following snippet
GITHUB_USER=<username>
GITHUB_API_TOKEN=<PAT goes here>
export GITHUB_USER GITHUB_API_TOKEN  

Issues

All :var placeholders must be replaced with appropriate values.

Create a milestone
curl -u "$GITHUB_USER:$GITHUB_API_TOKEN" \
     -H 'Content-type: text/json' \
     -X POST \
     -d '{"title":"1611","description":"Milestone 1611","due_on":"2016-09-14T12:00:00Z"}' \
     https://api.github.com/repos/:org/:repo/milestones
Close a milestone

Updates the state to closed

curl -u "$GITHUB_USER:$GITHUB_API_TOKEN" \
     -H 'Content-type: text/json' \
     -X PATCH \
     -d '{"title":"1611","state":"closed"}' \
     https://api.github.com/repos/:org/:repo/milestones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment