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

Rest endpoint to delete comments returning 404 #435

Open
pantelis-karamolegkos opened this issue Nov 13, 2023 · 0 comments
Open

Rest endpoint to delete comments returning 404 #435

pantelis-karamolegkos opened this issue Nov 13, 2023 · 0 comments

Comments

@pantelis-karamolegkos
Copy link

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,
.
.
.
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