Skip to content

A GitHub Action that integrates Google Gemini API into your workflows. Send prompts, set system instructions, and get AI-generated answers directly in your GitHub Actions.

License

Notifications You must be signed in to change notification settings

ViRGiL175/gemini-chat-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gemini Chat GitHub Action

This action allows you to interact with Google's Gemini API directly from your GitHub Actions workflows. You can send text prompts and system instructions to the Gemini model and receive its generated answer.

Features

  • Sends text prompts to the Gemini API (model gemini-2.5-flash via v1beta endpoint).
  • Supports optional system-level instructions to guide the model's behavior.
  • Validates required inputs (gemini-api-key, text).
  • Ensures curl and jq are available in the runner environment, installing them if necessary (on Debian/Ubuntu and Alpine-based images).
  • Outputs the generated answer from Gemini.
  • Provides detailed console output including the full JSON response from the API (for debugging) and the extracted answer.

Inputs

  • gemini-api-key
    • Description: Your API key for the Google Gemini API.
    • Required: true
  • text
    • Description: The main text prompt to send to the Gemini model.
    • Required: true
  • system-instruction
    • Description: Optional system-level instructions to steer the model's behavior. This can include context, desired format, or examples.
    • Required: false
    • Default: ""

Outputs

  • answer
    • Description: The text answer generated by Gemini.

Usage Example

name: Ask Gemini

on: [push]

jobs:
  chat_with_gemini:
    runs-on: ubuntu-latest
    steps:

      - name: Call Gemini Action
        id: gemini_response
        uses: ViRGiL175/gemini-chat-action@main
        with:
          gemini-api-key: ${{ secrets.GEMINI_API_KEY }}
          text: "Translate 'Hello, world!' to Spanish."
          system-instruction: "You are a helpful translation assistant."

      - name: Show Gemini's Answer
        run: echo "Gemini says: ${{ steps.gemini_response.outputs.answer }}"

Development

The action is a composite action, defined in action.yml. It uses curl to make requests to the Gemini API and jq to parse the JSON response.

Dependencies:

  • curl
  • jq

The action attempts to install these if they are not found on the runner, supporting apt-get (Debian/Ubuntu) and apk (Alpine). For other systems, ensure these tools are pre-installed on your runner.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue.

Disclaimer

This is an unofficial action and is not affiliated with Google. Use the Gemini API in accordance with Google's terms of service.

About

A GitHub Action that integrates Google Gemini API into your workflows. Send prompts, set system instructions, and get AI-generated answers directly in your GitHub Actions.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •