Make WordPress Core

Changeset 59169


Ignore:
Timestamp:
10/04/2024 03:35:13 PM (5 months ago)
Author:
desrosj
Message:

Build/Test Tools: Clean up PR comments after action is taken.

There’s now a number of automated comments left on pull requests to help contributors that a PR can easily be overridden with activity.

Some of the comments are only relevant until a specific action is taken. One such comment is for informing the PR author that a link to a Trac ticket is a requirement for considering any suggested changes.

This updates the pull request comment workflow to remove the comment once a link to a Trac ticket is properly included.

Props debarghyabanerjee.
Fixes #61567.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/.github/workflows/pull-request-comments.yml

    r58939 r59169  
    44on:
    55  pull_request_target:
    6     types: [ 'opened' ]
     6    types: [ 'opened', 'synchronize', 'reopened', 'edited' ]
    77  workflow_run:
    88    workflows: [ 'Test Build Processes' ]
     
    165165            github.rest.issues.createComment( commentInfo );
    166166
    167   # Leaves a comment on a pull request when no Trac ticket is included in the pull request description.
     167  # Manages comments reminding contributors to include a Trac ticket link when opening a pull request.
    168168  trac-ticket-check:
    169     name: Comment on a pull request when no Trac ticket is included
     169    name: Manage Trac ticket reminders for pull requests
    170170    runs-on: ubuntu-latest
    171171    permissions:
     
    174174    if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name == 'pull_request_target' && ! github.event.pull_request.draft && github.event.pull_request.state == 'open' }}
    175175    steps:
    176       - name: Check for Trac ticket and comment if missing
     176      - name: Check for Trac ticket and manage comment
    177177        uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
    178178        with:
     
    184184            const comments = ( await github.rest.issues.listComments( { owner, repo, issue_number: number } ) ).data;
    185185
    186             const hasMissingTicketComment = comments.some( comment =>
    187               comment.user.type === 'Bot' && comment.body.includes( 'Trac Ticket Missing' )
    188             );
    189 
    190             if ( hasMissingTicketComment ) return;
     186            const hasMissingTicketComment = comments.find( comment => comment.user.type === 'Bot' && comment.body.includes( 'Trac Ticket Missing' ) );
     187
     188            if ( hasMissingTicketComment ) {
     189              // Trac ticket link found, delete existing "Trac Ticket Missing" comment.
     190              await github.rest.issues.deleteComment( { owner, repo, comment_id: hasMissingTicketComment.id } );
     191              return;
     192            }
    191193
    192194            // No comment was found. Create one.
Note: See TracChangeset for help on using the changeset viewer.