Skip to content

Rest endpoint to delete comments returning 404 #435

Open
@pantelis-karamolegkos

Description

@pantelis-karamolegkos

I am saving the output of a gh cli invocation as follows:

gh pr view ${{ github.event.number }} --json comments > comments.json

I then want to iterate on the saved comments and conditionally delete some of them,

      - name: delete comments
        uses: actions/github-script@v6
        with:
          result-encoding: string
          script: |
            const fs = require('fs');
            const jsonData = JSON.parse(fs.readFileSync('comments.json', 'utf-8'));
            const comments = jsonData.comments;
            for (const cmnt of comments) {
              comment_id = cmnt.id
              if (cmnt.author.login == 'author-name' || cmnt.body == 'foo') {
                github.rest.issues.deleteComment({
                  owner: context.repo.owner,
                  repo: context.repo.repo,
                  comment_id: comment_id,
                })
              }
            }

This fails with:

 status: 404,
  response: {
    url: 'https://api.github.com/repos/MyOrganization/MyRepo/issues/comments/IC_kwDODse5xs5r1sLf',
    status: 404,
.
.
.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions