Open leordev opened 10 months ago
@leordev Per the discussion here: https://github.com/TBD54566975/sdk-development/issues/19#issuecomment-1805066695
...we might need two scripts since the web5-*
and tbdex-*
repos have different label sets.
I was hoping the user would change the script parameters here:
And then execute the scripts... So it would set the proper repos/labels depending on their use case.
If I add that as instructions above these parameters would suffice?
@leordev somewhat related, i wrote this script last week to create issues quickly. lmk what you think:
// github-create-issues.js
import 'dotenv/config';
import prompts from 'prompts';
import { Octokit } from '@octokit/core';
const octokit = new Octokit({
auth: process.env['GH_TOKEN']
});
const owner = process.env['GH_OWNER'];
const repo = process.env['GH_REPO'];
const getIssueDetails = async () => {
const questions = [
{
type: 'text',
name: 'title',
message: 'Issue title?',
validate: title => title.length < 5 ? `Title must be at least 5 characters long.` : true
},
{
type: 'text',
name: 'description',
message: 'Issue description?',
initial: '',
format: val => {
if (val) {
return val;
} else {
return undefined;
}
}
},
{
type: 'list',
name: 'assignees',
message: 'Assignees? (separate with commas)',
initial: process.env['ISSUE_ASSIGNEES'] || '',
separator: ','
},
{
type: 'list',
name: 'labels',
message: 'Labels? (separate with commas)',
separator: ',',
format: val => {
if (val.length === 1 && val[0] === '') {
return undefined
} else {
return val
}
}
},
{
type: 'confirm',
name: 'continue',
message: 'Would you like to enter another issue?',
initial: true
}
];
return await prompts(questions);
};
// Function to collect all issues
const collectIssues = async () => {
let issues = [];
let addMore = true;
while (addMore) {
console.log('\nPlease enter the issue details:');
const issueDetails = await getIssueDetails();
if (issueDetails.title) { // Making sure the title is entered
issues.push({
title: issueDetails.title,
description: issueDetails.description,
assignees: issueDetails.assignees,
labels: issueDetails.labels
});
}
if (!issueDetails.continue) {
addMore = false;
}
}
return issues;
};
// Main function to start the process
const main = async () => {
const issues = await collectIssues();
for (let issue of issues) {
await octokit.request('POST /repos/{owner}/{repo}/issues', {
owner: owner,
repo: repo,
title: issue.title,
body: issue.description,
assignees: issue.assignees,
labels: issue.labels,
headers: { 'X-GitHub-Api-Version': '2022-11-28' }
})
}
};
main();
works like so:
https://github.com/TBD54566975/sdk-development/assets/4887440/25a5807b-476e-4025-ab40-f48378c8b299
the script continues prompting until you say you're done creating issues and then creates all of them at once
assignees, labels, and repo can be pre-configured as environment variables or a .env
file. Was thinking we could adjust the script to look for a predetermined file name in the directory e.g. issues.json
. if that's present it skips the prompts, otherwise it jumps into prompting.
Was thinking we could adjust the script to look for a predetermined file name in the directory e.g. issues.json. if that's present it skips the prompts, otherwise it jumps into prompting.
Love this. I was a bit nervous of just entering a bunch of issues and in the end batching it up, because maybe I'd have lose something I entered that didn't go through, but since we have this json input, I'm fine with it because I will probably use my code editor to enter all of them there.
Another thing that should be included is the project (can be copied from my script functions)
@leordev can this be closed?
Also adds the label for cicd in the main script