jmikedupont2 / ai-ticket

The AI and Human powered ticket system to manage your AI based code generation with tickets
MIT License
21 stars 11 forks source link

Github Actions #15

Open jmikedupont2 opened 1 year ago

jmikedupont2 commented 1 year ago

To trigger a GitHub Action workflow when a new comment is created on an issue, you can use the issue_comment event with the created type in your workflow configuration. Here's how you can do it:

  1. Create a New Workflow YAML File:

    Inside your GitHub repository, create a new YAML file (e.g., respond_to_new_comment.yml) in the .github/workflows directory.

  2. Define the Workflow:

    In the YAML file, define your workflow as follows:

    name: Respond to New Comments
    
    on:
     issue_comment:
       types:
         - created
    
    jobs:
     respond:
       runs-on: ubuntu-latest
    
       steps:
         - name: Check Comment
           id: check-comment
           uses: actions/github-script@v4
           with:
             github-token: ${{ secrets.GITHUB_TOKEN }}
             script: |
               const comment = context.payload.comment.body.toLowerCase();
               // Add your logic here to respond to the new comment
               console.log('New comment:', comment);

    This workflow listens for the issue_comment event with the created type, which means it will trigger when a new comment is created on an issue.

  3. Add Your Logic:

    Inside the "Check Comment" step, you can add your custom logic to respond to the new comment. This logic could involve analyzing the comment content, posting a response comment, or performing other actions based on the comment.

  4. Commit and Push:

    Commit your workflow YAML file to your repository and push it to GitHub.

  5. Testing:

    To test the workflow, create a new comment on an issue in your repository. The workflow should trigger automatically in response to the new comment.

  6. Monitoring and Troubleshooting:

    Monitor the workflow runs in the "Actions" tab of your repository to ensure it's working as expected. If you encounter issues, you can review the workflow logs for debugging.

Make sure to adapt the workflow and the logic inside the "Check Comment" step to meet your specific requirements for responding to new comments on GitHub issues.

Creating a GitHub Action to respond to comments on an issue involves a series of steps and configuration files. Below is a high-level outline of how you can achieve this:

  1. Create a New Repository:

    Start by creating a new GitHub repository where you will host your GitHub Action workflow.

  2. Set Up Your Workflow:

    Inside your repository, create a directory (e.g., .github/workflows) to store your workflow files. Then, create a YAML file (e.g., respond_to_comments.yml) for your workflow.

  3. Define the Workflow:

    In your workflow YAML file, define the workflow. Here's a basic example of a workflow that responds to comments on an issue:

    name: Respond to Issue Comments
    
    on:
     issue_comment:
       types:
         - created
         - edited
    
    jobs:
     respond:
       runs-on: ubuntu-latest
    
       steps:
         - name: Check Comment
           id: check-comment
           uses: actions/github-script@v4
           with:
             github-token: ${{ secrets.GITHUB_TOKEN }}
             script: |
               const comment = context.payload.comment.body.toLowerCase();
               return { isBotCommand: comment.includes('/botcommand') };
         - name: Respond to Comment
           if: steps.check-comment.outputs.isBotCommand
           run: |
             echo "This is a response from your GitHub Action."
             # Add your logic here to respond to the comment

    This workflow listens for issue comments and checks if the comment contains a specific trigger phrase (e.g., /botcommand). If it finds the trigger phrase, it responds to the comment.

  4. Add Your Logic:

    In the "Respond to Comment" step, you can add your custom logic to respond to the comment. This could involve posting a comment using the GitHub API or performing other actions based on the comment content.

  5. Commit and Push:

    Commit your workflow YAML file to your repository and push it to GitHub.

  6. Configure Secrets:

    If your custom logic requires authentication (e.g., if you need to post comments on behalf of a bot account), you should configure secrets in your GitHub repository for storing sensitive information like API tokens.

  7. Test Your Workflow:

    Create an issue in your repository and leave a comment with the trigger phrase (e.g., /botcommand) to test your GitHub Action workflow.

  8. Monitor and Troubleshoot:

    Monitor the workflow runs in the "Actions" tab of your repository to ensure it's working as expected. If you encounter issues, you can review the workflow logs for debugging.

Remember to adapt the workflow to your specific requirements and customize the "Respond to Comment" step to perform the actions you need in response to comments on issues.

nalbion commented 1 year ago

I've done something like this - https://github.com/nalbion/auto-gpt-action

jmikedupont2 commented 1 year ago

Thats amazing, thank you @nalbion I like how you used peter-evans/create-or-update-comment@v1 that gives me a greate idea that we can call generic github actions via the agent as well and use github actions as defintions for the agent tasks

jmikedupont2 commented 1 year ago

So I think this would be great to have the autogpt run on the git comment action so that each comment will invoke autogpt or it will wait for a comment to run.

jmikedupont2 commented 1 year ago

The waiting in the gui should be able to be replaced by a button or a link in the comment. the link could take me to a streamlit app that uses github api to make some action for me using the command that would run the next step of the autogpt.