Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nickofthyme/gh-project-v2-add-item
Script to add github issues to v2 projects
https://github.com/nickofthyme/gh-project-v2-add-item
Last synced: 7 days ago
JSON representation
Script to add github issues to v2 projects
- Host: GitHub
- URL: https://github.com/nickofthyme/gh-project-v2-add-item
- Owner: nickofthyme
- Created: 2023-04-13T14:38:27.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-04-13T15:19:47.000Z (over 1 year ago)
- Last Synced: 2024-04-18T05:17:51.394Z (7 months ago)
- Language: TypeScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gh-project-v2-add-item
A script to add github issues to v2 projects
:warning: This is extremely manual and untested, so use at your own risk :smile:
## To configure
### Setup base graphQL config
The `utils.ts` file contains a `graphql` request wrapper method that is used across the scripts to call the github graphQL endpoint. Update this script with your `org`, `repo`, `projectId` and `projectNumber`.
You can find the `projectId` from the `org` and `projectNumber` by using the [GitHub GraphQL Explorer](https://docs.github.com/en/graphql/overview/explorer).
```graphql
query {
organization(login: "elastic") {
projectV2(number: 1141) {
id
}
}
}
```### Setup the GitHub token
The `graphql` method using the `GITHUB_TOKEN` loaded from a root level `.env` file.
```
# .env
GITHUB_TOKEN=""
```> This token should have read access to `repo` and `project` scopes. Get yours at https://github.com/settings/tokens.
### Tweak the request to your needs
The `add_issues.ts` file contains scripts to fetch all issues, in 100 count batches, based on the defined qraphql query. Issues already added to the given project are filtered out, (see https://github.com/nickofthyme/gh-project-v2-add-item/blob/main/add_issues.ts#L34-L37 and https://github.com/nickofthyme/gh-project-v2-add-item/blob/main/add_issues.ts#L105).
> It may help for testing to set the count param on the `getIssues` function to `1`, before opening up the flood gates :smile:
Then it loops through all issues as adds them to the defined project.
Finally it updates the newly added project item. You may want to change this update method to suit your needs, currently it just updates a hardcoded field to a defined set of options. You would need to find the `node_id` for these items manually using [GitHub GraphQL Explorer](https://docs.github.com/en/graphql/overview/explorer).
## To run
Load dependencies
```
yarn
```Run script
```
yarn run
```