Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddSubIssue functions missing #519

Open
cheeragpatel opened this issue Jan 23, 2025 · 0 comments
Open

AddSubIssue functions missing #519

cheeragpatel opened this issue Jan 23, 2025 · 0 comments

Comments

@cheeragpatel
Copy link

Describe the bug
github.rest.issues.addSubIssue is not a function, octokit has the function in the latest release

To Reproduce
Run a github action to create a sub issue:

      - name: Create linked sub-issues from tasklist
        uses: actions/github-script@v7.0.1
        with:
          script: |
            const issueBody = context.payload.issue.body
            const parentIssueNumber = context.payload.issue.number

            // Extract the content between ```[tasklist] and ```
            const matchTasklist = issueBody.match(/```\[tasklist\]([\s\S]*?)```/)
            if (!matchTasklist) {
              core.info('No [tasklist] section found in the issue body.')
              return
            }

            const tasklistContent = matchTasklist[1]
            // Identify lines that match '- [ ] ...'
            const tasks = tasklistContent.match(/^- \[ \] .+/gm) || []

            for (const task of tasks) {
              const title = task.replace(/^- \[ \] /, '').trim()
              const newIssue = await github.rest.issues.create({
                owner: context.repo.owner,
                repo: context.repo.repo,
                title: title,
                body: `Sub-issue of #${parentIssueNumber}`
              })

              // Link the sub issue to the parent issue
              await github.rest.issues.addSubIssue({
                owner: context.repo.owner,
                repo: context.repo.repo,
                issue_number: parentIssueNumber,
                sub_issue_id: newIssue.data.id
              })

               // Comment on the parent issue linking the new sub-issue
              await github.rest.issues.createComment({
                owner: context.repo.owner,
                repo: context.repo.repo,
                issue_number: parentIssueNumber,
                body: `Created sub-issue: #${newIssue.data.number} for task: "${title}"`
              })             
            }

Expected behavior
A sub issue should be created based on the inputs

Screenshots

Error

Additional context
Trying to create sub issues based off an issue template and hitting this error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant