Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
message-circle

GitHub Action

Create GitHub Discussion

v1.1.0

Create GitHub Discussion

message-circle

Create GitHub Discussion

GitHub Action to create a new GitHub Discussion

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Create GitHub Discussion

uses: abirismyname/[email protected]

Learn more about this action in abirismyname/create-discussion

Choose a version

Create-Discussion

Create a new GitHub Discussion with GitHub Actions

code style: prettier

About

This action allows you to create a new GitHub Discussion with GitHub Actions.

Usage

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

    - name: Create a new GitHub Discussion
      id: create-discussion
      uses: abirismyname/[email protected]
      env:
        GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}      
      with:
        title: Feelings
        body: |
          Let's talk!
        repository-id: ${{ secrets.REPO_ID }}
        category-id: ${{ secrets.CAT_ID }}  
    - name: Print discussion url and id
      run: |
        echo discussion-id: ${{steps.create-discussion.outputs.discussion-id}} 
        echo discussion-url: ${{steps.create-discussion.outputs.discussion-url}}             

Inputs

The following inputs are required:

  • title: The title of the discussion
  • body: The body of the discussion
  • body-filepath: The path to a file containing the body of the new discussion (takes precedence over body).
  • repository-id: The ID of the repository for the new discussion
  • category-id: The ID of the category for the new discussion

Obtaining the repository-id and category-id

You can find repository-id and category-id using GitHub's GraphQL Explorer. Replace <REPO_NAME> and <REPO_OWNER> with the repo you want to update.

query MyQuery {
  repository(name: "<REPO_NAME>", owner: "<REPO_OWNER>") {
    id
    discussionCategories(first: 10) {
      edges {
        node {
          id
          name
        }
        cursor
      }
    }
  }
}

Outputs

This action provides the following outputs:

  • discussion-id: ID of created discussion
  • discussion-url: URL of created discussion

Example

This repo contains an example workflow that contains this action.

Credits