This action generates an image using the OpenAI Image Generation API.
Create a workflow (eg: .github/workflows/generate-image.yml
). See Creating a Workflow file.
name: Image Generation
on:
issue_comment:
types: [created]
jobs:
run:
if: ${{ startsWith(github.event.comment.body, '/image') }}
name: Run Action
runs-on: ubuntu-latest
steps:
- id: prompt
uses: actions/github-script@v3
with:
script: return context.payload.comment.body.replace('/image', '').trim()
- id: generate-image
uses: austenstone/openai-image-generation@main
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
prompt: ${{ steps.prompt.outputs.result }}
- run: gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments -f body="![image](${{ steps.generate-image.outputs.image }})"
env:
GH_TOKEN: ${{ github.token }}
Various inputs are defined in action.yml
:
Name | Description | Default |
---|---|---|
openai‑api‑key | OpenAI API key. | |
prompt | Prompt to use for image generation. | |
size | Size of the image to generate. | 512x512 |
To get more help on the Actions see documentation.