mkglass

Bulk-create GitHub issues from Markdown files using GitHub CLI

Jun 22nd, 2026 (edited)
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.69 KB | Software | 0 0
  1. # Bulk-create GitHub issues from Markdown files using GitHub CLI
  2.  
  3. I wanted a simple way to batch create a small GitHub issue backlog from local Markdown files.
  4.  
  5. GitHub Issues are not stored in the repo itself, so you cannot create issue files locally, commit them, and push them to GitHub. Issues live in GitHub’s database.
  6.  
  7. But you can use the GitHub CLI to create issues from local Markdown files.
  8.  
  9. This approach lets you:
  10.  
  11. write and review issue bodies locally before creating them
  12. create labels first
  13. explicitly target the correct repo
  14. create a batch of issues without copy/pasting each one into GitHub
  15. keep the local drafts out of your repo with .gitignore
  16. Assumptions
  17. GitHub CLI is installed
  18. You are authenticated with gh auth login
  19. You are on Windows
  20. Your local folder looks like this:
  21. issue-drafts/
  22. create-github-issues.bat
  23. issues/
  24. 001-fix-login-error.md
  25. 002-add-dark-mode.md
  26. 003-clean-up-state-management.md
  27.  
  28. If this folder lives inside your repo, add it to .gitignore:
  29.  
  30. /issue-drafts/
  31.  
  32. Before running the script, edit this line:
  33.  
  34. set REPO=YourUserName/YourRepoName
  35.  
  36. Example:
  37.  
  38. set REPO=octocat/hello-world
  39.  
  40. Then run:
  41.  
  42. create-github-issues.bat
  43.  
  44. The issues will be created directly in GitHub. No commit or push is required.
  45.  
  46. create-github-issues.bat
  47. ---
  48. @echo off
  49. setlocal EnableExtensions
  50.  
  51. set REPO=YourUserName/YourRepoName
  52.  
  53. echo Verifying GitHub CLI authentication...
  54. gh auth status
  55. if errorlevel 1 (
  56. echo.
  57. echo GitHub CLI is not authenticated. Run:
  58. echo gh auth login
  59. echo.
  60. pause
  61. exit /b 1
  62. )
  63.  
  64. echo.
  65. echo Verifying target repository...
  66. gh repo view %REPO% --json nameWithOwner,url
  67. if errorlevel 1 (
  68. echo.
  69. echo Could not access %REPO%.
  70. echo Check your GitHub login and repo permissions.
  71. echo.
  72. pause
  73. exit /b 1
  74. )
  75.  
  76. echo.
  77. echo Creating labels if they do not already exist...
  78.  
  79. call :CreateLabel bug "d73a4a" "Something is not working"
  80. call :CreateLabel feature "a2eeef" "New functionality"
  81. call :CreateLabel technical-debt "d4c5f9" "Internal cleanup or architecture work"
  82.  
  83. echo.
  84. echo Current labels:
  85. gh label list --repo %REPO% --limit 30
  86.  
  87. echo.
  88. echo Creating issues...
  89. echo.
  90.  
  91. call :CreateIssue "Fix login error message alignment" "issues\001-fix-login-error.md" "bug"
  92. call :CreateIssue "Add dark mode" "issues\002-add-dark-mode.md" "feature"
  93. call :CreateIssue "Clean up state management" "issues\003-clean-up-state-management.md" "technical-debt"
  94.  
  95. echo.
  96. echo Done. Review issues at:
  97. echo https://github.com/%REPO%/issues
  98. echo.
  99. pause
  100. exit /b 0
  101.  
  102. :CreateLabel
  103. gh label create "%~1" --repo %REPO% --color "%~2" --description "%~3" >nul 2>nul
  104. if errorlevel 1 (
  105. echo Label exists or could not be created: %~1
  106. ) else (
  107. echo Created label: %~1
  108. )
  109. exit /b 0
  110.  
  111. :CreateIssue
  112. set TITLE=%~1
  113. set BODY=%~2
  114. set LABEL=%~3
  115.  
  116. echo Creating issue: %TITLE%
  117.  
  118. gh issue create ^
  119. --repo %REPO% ^
  120. --title "%TITLE%" ^
  121. --body-file "%BODY%" ^
  122. --label "%LABEL%"
  123.  
  124. if errorlevel 1 (
  125. echo FAILED: %TITLE%
  126. ) else (
  127. echo Created: %TITLE%
  128. )
  129.  
  130. echo.
  131. exit /b 0
  132.  
  133. ---
  134.  
  135. issues/001-fix-login-error.md
  136. ---
  137. ## Problem
  138.  
  139. The login form error message is visually misaligned with the input field.
  140.  
  141. ## Expected behavior
  142.  
  143. The error message should align cleanly under the field and remain readable at different viewport sizes.
  144.  
  145. ## Notes
  146.  
  147. This appears to be a layout/CSS issue rather than a validation logic issue.
  148.  
  149. ---
  150.  
  151. issues/002-add-dark-mode.md
  152. ---
  153. ## Goal
  154.  
  155. Add a dark mode option to the application.
  156.  
  157. ## Initial scope
  158.  
  159. - Add a user-facing toggle
  160. - Persist the selected mode locally
  161. - Ensure the default theme still works without JavaScript errors
  162.  
  163. ## Notes
  164.  
  165. This should be implemented without introducing a framework or build step.
  166.  
  167. ---
  168.  
  169. issues/003-clean-up-state-management.md
  170. ---
  171. ## Goal
  172.  
  173. Clean up the state management code.
  174.  
  175. ## Why
  176.  
  177. Application values are becoming harder to track as more controls are added.
  178.  
  179. ## Suggested direction
  180.  
  181. Centralize state updates through a small set of helper functions so future features can reuse the same flow.
  182.  
  183. ## Notes
  184.  
  185. This is internal cleanup and should not change visible behavior.
  186.  
  187. ---
  188.  
  189. # Optional verification commands
  190.  
  191. You can verify the target repo before creating issues:
  192.  
  193. gh repo view YourUserName/YourRepoName --json nameWithOwner,url
  194.  
  195. You can list existing labels:
  196.  
  197. gh label list --repo YourUserName/YourRepoName
  198.  
  199. You can list created issues:
  200.  
  201. gh issue list --repo YourUserName/YourRepoName --limit 20
  202. Notes
  203.  
  204. This is not really “committing issues to GitHub.” The Markdown files are just local drafts.
  205.  
  206. The actual issue creation happens through:
  207.  
  208. gh issue create --body-file
  209.  
  210. That command creates the issue directly in GitHub.
Advertisement
Add Comment
Please, Sign In to add comment