This repository demonstrates how to use the Swytchcode CLI and TypeScript SDK to interact with the GitHub API to dynamically create issues.
- Node.js (v18 or higher)
- A GitHub account
First, install the Swytchcode CLI globally on your machine:
npm install -g swytchcodeFork this repository to your own account, then clone it locally:
git clone https://github.com/<YOUR_GITHUB_USERNAME>/github-issue-swytchcode.git
cd github-issue-swytchcodeInstall the local project packages and download the Swytchcode integration:
npm install
swytchcode bootstrap- Copy the
.env.examplefile to create a new.envfile:cp .env.example .env
- Generate a Personal Access Token (PAT) with
repopermissions:- Go to https://github.com/settings/tokens
- Click "Generate new token (classic)"
- Check the
reposcope box - Generate and copy the token (starts with
ghp_)
- Open
.envand paste your PAT.
Execute the main script:
npm run devThe script automatically detects your forked repository URL and uses your PAT to create a test issue on it. Check the terminal output for the link to your newly created issue.
- GITHUB_PAT is not set: Ensure you renamed
.env.exampleto.env. - Could not read git remote: Ensure you ran the script from inside the cloned git repository folder.
- 401 Unauthorized / Bad Credentials: Your token may be invalid. Generate a new one and update
.env. - 404 Not Found / Permission Denied: Ensure your token has the
reposcope enabled.