peter-evans / create-or-update-comment

A GitHub action to create or update an issue or pull request comment
MIT License
706 stars 113 forks source link

Unable to update the comment on github discussion room, please help #187

Closed zameer712 closed 1 year ago

zameer712 commented 1 year ago

Hi @peter-evans / anyone

Hope you are doing well , we are using your repo at our organization noticed few issues like issue-number and comment-id are hardcoded in your github action can we make it more generic like depends on the run like below yaml

Use case :

  1. whenever their is an new discussion room opened or modified .
  2. it should automatically respond with an GIF in a comic way and it will convey that we are taking care of the issue
  3. it should update that new or old discussion room with the ticket

Below is my workflow file please do help

name: Auto Reply to Discussions

on: workflow_dispatch: discussion: types: [created, edited, labeled, answered, unanswered] discussion_comment: types: [created, edited, labeled, answered, unanswered]

jobs: auto_reply: runs-on: ubuntu-latest

steps:
  - name: Checkout repository
    uses: actions/checkout@v2
    with:
      repository: ${{ secrets.REPO }}
      GH_TOKEN: ${{ secrets.SECRET_TOKEN }}  

  - name: Get discussion payload
    uses: actions/github-script@v4
    with:
      github-token: ${{ secrets.SECRET_TOKEN }}
      script: |
        console.log(JSON.stringify(context.payload))

  - name: Login
    uses: atlassian/gajira-login@v3
    env:
      JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
      JIRA_USER_EMAIL: ${{ secrets.JIRA_CLOUD_USER_EMAIL }}
      JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}

  - name: Handle discussion event
    uses: peter-evans/create-or-update-comment@v3
    with:
      issue-number: ${{ github.event.discussion.number }}
      token: ${{ secrets.SECRET_TOKEN }}
      body: |
        A new discussion event has occurred!

        **Action**: ${{ github.event.action }}
        **Discussion ID**: ${{ github.event.discussion.id }}
        **Discussion Title**: ${{ github.event.discussion.title }}
        **Discussion URL**: ${{ github.event.discussion.html_url }}
        **Repository Name**: ${{ github.event.repository.name }}
        Here's a GIF to make it more interactive: https://github.com/<organization-name>/athena-poc-design1/blob/06ab282c735c3d6bab0b760e198144301a5eb2b5/Automated_response.gif
      reactions: heart
peter-evans commented 1 year ago

Hi @zameer712

Unfortunately, the API for discussion comments is different from PR/issues, so this action doesn't work for discussions.