GithubHelp home page GithubHelp logo

wesleyscholl / create-discussion-comment Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 4.31 MB

A GitHub Action for Creating Discussion Comments ⌨️💬✅

Home Page: https://github.com/marketplace/actions/create-discussion-comment

License: MIT License

comment comment-system commenting comments discuss discussion discussion-board discussion-forum discussion-platform discussions

create-discussion-comment's Introduction

Create Discussion Comment ⌨️💬✅

Create Comments on Exsiting GitHub Discussions using GitHub Actions

Tests

Code Style: prettier

GitHub Marketplace

About

This action allows you to add comments to GitHub Discussions using GitHub Actions.

Usage

In your workflow, to create a new comment on a discussion topic, include a step like this:

    - name: Run create-discussion-comment
      uses: wesleyscholl/[email protected]
      id: create-comment
      with:
        token: ${{ secrets.DISCUSS_TOKEN }}
        body: "This is a test comment from a GitHub action"          
        discussion-id: 'D_kwdje64ife75s9o'
        client-mutation-id: '1234'

Ensure you provide the discussion ID, this can be found using the GitHub GraphQL Explorer. (See below)

Action Inputs

Name Description Requried? Default
token A GitHub PAT is required. Ensure the PAT has discussion: write and public_repo: read for public repos and repo: write for private repositories. See more details about tokens here PAT. Yes N/A
body The contents of the comment in string format. No "Comment provided by GitHub Action create-discussion-comment"
discussion-id The node ID of the discussion to comment on. This can be found using the GitHub GraphQL explorer, more details below. Yes N/A
client-mutation-id A unique identifier for the client performing the mutation. No "1234"
replyToId The node ID of the discussion comment to reply to. If absent, the created comment will be a top-level comment. No N/A

Action Outputs

Name Description Data Model
clientMutationId The unique identifier provided as an input. See below
comment The discussion comment that was created. See below

Response

{"data":
{"addDiscussionComment":
{"clientMutationId":"1234",
"comment":{
    "id":"DC_kwdje64ife75s9o",
    "body":"This is a test comment from a GitHub action"
    }}}}

Obtaining the discussion-id

You can find your discussion-id and using GitHub's GraphQL Explorer. Replace <REPO_NAME> and <REPO_OWNER> to find the discussion id you wish to comment on.

GraphQL Query

query {
  repository(owner: "<REPO_OWNER>`", name: "cohere") {
    discussions(first: 5) {
      edges {
        node {
          # The value below is the discussion-id
          id
          title
          category {
            id
            name
          }
          body
          id
        }
      }
    }
  }
}

GraphQL Output

{
  "data": {
    "repository": {
      "discussions": {
        "edges": [
          {
            "node": {
              // This is the discussion-id  
              "id": "D_kwdje64ife75s9o",
              "title": "Test Topic Title - Insert Question Here",
              "category": {
                "id": "DIC_kwSWEbhiT23EW-rr",
                "name": "Q&A"
              },
              "body": "This is the body of the discussion topic"
            }
          }
        ]
      }
    }
  }
}

Example

Example workflow can be found here.

Credits

Inspired by:

create-discussion-comment's People

Contributors

wesleyscholl avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

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.