Creating GitHub Projects Draft Issues from CLI with gh projects item-create
I’ll introduce the gh projects item-create
command for creating draft issues in GitHub Projects from the CLI.
scopes: project
PermissionsYou can’t use the gh projects command without scopes: project
permissions, so grant permissions with gh auth refresh -s project
.
$ gh auth status
github.com
✓ Logged in to github.com as shige (/Users/your_username/.config/gh/hosts.yml)
✓ Git operations for github.com configured to use https protocol.
✓ Token: gho_************************************
✓ Token scopes: gist, read:org, repo, workflow
$ gh auth refresh -s project
? Authenticate Git with your GitHub credentials? Yes
! First copy your one-time code: XXXX-XXXX
Press Enter to open github.com in your browser...
$ gh auth status
github.com
✓ Logged in to github.com as shige (/Users/your_username/.config/gh/hosts.yml)
✓ Git operations for github.com configured to use https protocol.
✓ Token: gho_************************************
✓ Token scopes: gist, project, read:org, repo, workflow
gh-projects
Extensiongh extension install github/gh-projects
gh projects item-create
Help$ gh projects item-create
Usage:
projects item-create [number] [flags]
Examples:
# create a draft issue in the current user's project 1 with title "new item" and body "new item body"
gh projects item-create 1 --user "@me" --title "new item" --body "new item body"
# create a draft issue in user monalisa's project 1 with title "new item" and body "new item body"
gh projects item-create 1 --user monalisa --title "new item" --body "new item body"
# create a draft issue in org github's project 1 with title "new item" and body "new item body"
gh projects item-create 1 --org github --title "new item" --body "new item body"
# add --format=json to output in JSON format
Flags:
--body string Body of the draft issue item.
--format string Output format, must be 'json'.
-h, --help help for item-create
--org string Login of the organization owner.
--title string Title of the draft issue item.
--user string Login of the user owner. Use "@me" for the current user.
required flag(s) "title" not set
gh projects item-create
Here’s a sample script for creating draft issues in GitHub Projects using the gh projects item-create
command:
YOUR_GH_PJ_NUM=1
gh projects item-create $YOUR_GH_PJ_NUM
--org codenote-net
--title "new item"
--body "new item body"
That’s all from the Gemba - I want to make use of the gh projects item-create
command for adding draft issues to GitHub Projects from the CLI.