Rest endpoint to delete comments returning 404

Abierto
#435 0 comentarios 6 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
42/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
github, github-actions, javascript
Área
api, ci-cd

Línea de trabajo

Start with the workflow snippet in the issue and the linked GitHub REST documentation for deleting an issue comment. Compare the comment identifiers saved by gh pr view --json comments with the comment_id passed to github.rest.issues.deleteComment, then verify the documented request against the reported 404 response. Done means the conditional deletion works for the saved comments.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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,
.
.
.
Lenguaje dominante
TypeScript
Estrellas
5k
Forks
586
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de actions/github-script

Todos los issues de actions/github-script

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.