Coder Social home page Coder Social logo

comment-hider's Introduction

Github Action to hide Bot comments

build-test

Comment-hider action automatically hides bot comments posted to PR.

  • Automatically hide certain users' comments posted to PR. (The default is github-actions[bot].)

Sample Workflows

Posting the results of CI/CD in the PR comments is a common practice. Comment-hider action is useful for hiding outdated posts in these cases.

on:
  pull_request:
steps:
- uses: actions/checkout@v2

- uses: kanga333/comment-hider@master
  name: Hide bot comments
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    # See action.yml for other options you can specify

- id: cicd
  run: |
    echo "Run some kind of CI/CD."

- uses: actions/[email protected]
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    script: |
      const output = `${{ steps.cicd.outputs.stdout }}`;
      github.issues.createComment({
        issue_number: context.issue.number,
        owner: context.repo.owner,
        repo: context.repo.repo,
        body: output
      })

comment-hider's People

Contributors

akuli avatar bgpat avatar dependabot[bot] avatar kanga333 avatar prince-chrismc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

comment-hider's Issues

Hide all comments with exception to the last

Hi ๐Ÿ‘‹

I really like your action and I'd like to contribute a small change.
Currently this action hide all comments which is helpful but I think it would be great if the last comment was left visible. I think this will make most people's desires (usually you want to see the last annoying "your commit fails in CI" message)

If this is a feature you are interested in I'd love to open a PR with a possible implementation!

Iterate over all comments

Thank you for this action!

Currently, only the first 30 comments can be hidden.
When the comments are queried here

const resp = await this.octokit.rest.issues.listComments({

the default of 30 is used (see docs).

To get all comments, we would have to get the comments repeatedly, i.e. per_page=100 and then query consecutive pages until we are done.

"on: workflow_run" support: providing issue number manually

I wanted to use this action with on: workflow_run, like this: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/

But then it couldn't access the issue number (actually, pull request number), which must be provided as an explicit input to each actions when using on: workflow_run.

I started working on a PR that adds an issue_number input, so that you could do something like this, assuming the issue number is stored in issue_number.txt:

- name: Read PR number
  id: issue-number
  run: echo "::set-output name=issueNumber::$(cat issue_number.txt)"
- uses: kanga333/comment-hider@...  # version tag or full commit hash
  name: Hide old comments
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    issue_number: ${{ steps.issue-number.outputs.issueNumber }}

The problem is that it takes two steps to first make the issue number available in ${{ ... }} syntax, and then to call the comment hider. Alternatively, the comment hider could read the issue number from a file:

- uses: kanga333/comment-hider@...  # version tag or full commit hash
  name: Hide old comments
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    issue_number_file: issue_number.txt

Which way is better?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.