Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Bulk-create GitHub issues from Markdown files using GitHub CLI
- I wanted a simple way to batch create a small GitHub issue backlog from local Markdown files.
- 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.
- But you can use the GitHub CLI to create issues from local Markdown files.
- This approach lets you:
- write and review issue bodies locally before creating them
- create labels first
- explicitly target the correct repo
- create a batch of issues without copy/pasting each one into GitHub
- keep the local drafts out of your repo with .gitignore
- Assumptions
- GitHub CLI is installed
- You are authenticated with gh auth login
- You are on Windows
- Your local folder looks like this:
- issue-drafts/
- create-github-issues.bat
- issues/
- 001-fix-login-error.md
- 002-add-dark-mode.md
- 003-clean-up-state-management.md
- If this folder lives inside your repo, add it to .gitignore:
- /issue-drafts/
- Before running the script, edit this line:
- set REPO=YourUserName/YourRepoName
- Example:
- set REPO=octocat/hello-world
- Then run:
- create-github-issues.bat
- The issues will be created directly in GitHub. No commit or push is required.
- create-github-issues.bat
- ---
- @echo off
- setlocal EnableExtensions
- set REPO=YourUserName/YourRepoName
- echo Verifying GitHub CLI authentication...
- gh auth status
- if errorlevel 1 (
- echo.
- echo GitHub CLI is not authenticated. Run:
- echo gh auth login
- echo.
- pause
- exit /b 1
- )
- echo.
- echo Verifying target repository...
- gh repo view %REPO% --json nameWithOwner,url
- if errorlevel 1 (
- echo.
- echo Could not access %REPO%.
- echo Check your GitHub login and repo permissions.
- echo.
- pause
- exit /b 1
- )
- echo.
- echo Creating labels if they do not already exist...
- call :CreateLabel bug "d73a4a" "Something is not working"
- call :CreateLabel feature "a2eeef" "New functionality"
- call :CreateLabel technical-debt "d4c5f9" "Internal cleanup or architecture work"
- echo.
- echo Current labels:
- gh label list --repo %REPO% --limit 30
- echo.
- echo Creating issues...
- echo.
- call :CreateIssue "Fix login error message alignment" "issues\001-fix-login-error.md" "bug"
- call :CreateIssue "Add dark mode" "issues\002-add-dark-mode.md" "feature"
- call :CreateIssue "Clean up state management" "issues\003-clean-up-state-management.md" "technical-debt"
- echo.
- echo Done. Review issues at:
- echo https://github.com/%REPO%/issues
- echo.
- pause
- exit /b 0
- :CreateLabel
- gh label create "%~1" --repo %REPO% --color "%~2" --description "%~3" >nul 2>nul
- if errorlevel 1 (
- echo Label exists or could not be created: %~1
- ) else (
- echo Created label: %~1
- )
- exit /b 0
- :CreateIssue
- set TITLE=%~1
- set BODY=%~2
- set LABEL=%~3
- echo Creating issue: %TITLE%
- gh issue create ^
- --repo %REPO% ^
- --title "%TITLE%" ^
- --body-file "%BODY%" ^
- --label "%LABEL%"
- if errorlevel 1 (
- echo FAILED: %TITLE%
- ) else (
- echo Created: %TITLE%
- )
- echo.
- exit /b 0
- ---
- issues/001-fix-login-error.md
- ---
- ## Problem
- The login form error message is visually misaligned with the input field.
- ## Expected behavior
- The error message should align cleanly under the field and remain readable at different viewport sizes.
- ## Notes
- This appears to be a layout/CSS issue rather than a validation logic issue.
- ---
- issues/002-add-dark-mode.md
- ---
- ## Goal
- Add a dark mode option to the application.
- ## Initial scope
- - Add a user-facing toggle
- - Persist the selected mode locally
- - Ensure the default theme still works without JavaScript errors
- ## Notes
- This should be implemented without introducing a framework or build step.
- ---
- issues/003-clean-up-state-management.md
- ---
- ## Goal
- Clean up the state management code.
- ## Why
- Application values are becoming harder to track as more controls are added.
- ## Suggested direction
- Centralize state updates through a small set of helper functions so future features can reuse the same flow.
- ## Notes
- This is internal cleanup and should not change visible behavior.
- ---
- # Optional verification commands
- You can verify the target repo before creating issues:
- gh repo view YourUserName/YourRepoName --json nameWithOwner,url
- You can list existing labels:
- gh label list --repo YourUserName/YourRepoName
- You can list created issues:
- gh issue list --repo YourUserName/YourRepoName --limit 20
- Notes
- This is not really “committing issues to GitHub.” The Markdown files are just local drafts.
- The actual issue creation happens through:
- gh issue create --body-file
- That command creates the issue directly in GitHub.
Advertisement
Add Comment
Please, Sign In to add comment