Create a new GitHub Discussion with GitHub Actions
This action allows you to create a new GitHub Discussion with GitHub Actions.
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}}
The following inputs are required:
title
: The title of the discussionbody
: The body of the discussionbody-filepath
: The path to a file containing the body of the new discussion (takes precedence overbody
).**repository-id
: The ID of the repository for the new discussioncategory-id
: The ID of the category for the new discussion.
** If you are using body-filepath
be sure to add a actions/checkout
action before this action in the workflow to make sure the file exists in the action workspace.
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
}
}
}
}
This action provides the following outputs:
discussion-id
: ID of created discussiondiscussion-url
: URL of created discussion
This repo contains an example workflow that contains this action.
- 🙇 Based on swinton/commit.
- 🙇 @imjohnbo for the inspiration.