This is a GitHub Actions for running OpenAI's chat on GitHub Issues.
- Prepare a yaml file that describes the workflow below.
- Place it in the default branch.
name: OpenAI Chat
on:
issues:
types: [opened]
issue_comment:
types: [created]
jobs:
chat:
name: Chat
runs-on: ubuntu-latest
steps:
- uses: snnaplab/openai-chat-on-issues@v1
with:
openai-key: ${{ secrets.OPENAI_KEY }}
model: 'gpt-4' # option, default is 'gpt-3.5-turbo'
system-prompt: | # option
You are a helpful assistant.
Available models are listed in Model endpoint compatibility ( This action use /v1/chat/completions
endpoint ).
However, it may depend on the circumstances of the account that issued the key.
name: OpenAI Chat
on:
issues:
types: [opened]
issue_comment:
types: [created]
concurrency: # add these
group: ${{ github.workflow }}-${{ github.event.issue.number || github.run_id }}
cancel-in-progress: true
...
name: OpenAI Chat
on:
issues:
types: [opened]
issue_comment:
types: [created]
jobs:
chat:
name: Chat
if: startsWith(github.event.issue.body, '/openai ') || startsWith(github.event.comment.body, '/openai ') # add this
runs-on: ubuntu-latest
steps:
- uses: snnaplab/openai-chat-on-issues@v1
...
name: OpenAI Chat
on:
issues:
types: [opened]
issue_comment:
types: [created]
jobs:
chat:
name: Chat
if: contains(github.event.issue.title, 'openai') # add this
runs-on: ubuntu-latest
steps:
- uses: snnaplab/openai-chat-on-issues@v1
...
name: OpenAI Chat
on:
issues:
types: [opened]
issue_comment:
types: [created]
jobs:
chat:
name: Chat
if: contains(github.event.issue.labels.*.name, 'openai') # add this
runs-on: ubuntu-latest
steps:
- uses: snnaplab/openai-chat-on-issues@v1
...
Conversations between users, or comments you don't want AI to refer to.
name: OpenAI Chat
on:
issues:
types: [opened]
issue_comment:
types: [created]
jobs:
chat:
name: Chat
runs-on: ubuntu-latest
steps:
- uses: snnaplab/openai-chat-on-issues@v1
with:
openai-key: ${{ secrets.OPENAI_KEY }}
ignore-keywords: | # add these
AI bot ignore
issues: write
permission is required.
If necessary, specify in the workflow as follows.
name: OpenAI Chat
on:
issues:
types: [opened]
issue_comment:
types: [created]
permissions: # add these
issues: write
...
It is convenient to prepare frequently used prompts as custom templates for issues. ref: Configuring issue templates for your repository
The issue_comment
trigger fires even on pull request comments.
This action is passed through, so there is no problem, but to prevent extra jobs from starting, do the following:
name: OpenAI Chat
on:
issues:
types: [opened]
issue_comment:
types: [created]
jobs:
chat:
name: Chat
if: github.event.issue.pull_request == null # add this
runs-on: ubuntu-latest
steps:
- uses: snnaplab/openai-chat-on-issues@v1
...
- (Japanese) GitHub Issues を ChatGPT のようにするツールを作った話