Ai Coding Tools

How to Build a Personal GitHub Action with AI in Just 1 Hour

By BTW Team3 min read

How to Build a Personal GitHub Action with AI in Just 1 Hour

Creating a custom GitHub Action can seem daunting, especially if you’re juggling multiple side projects or indie ventures. But what if I told you that you could build a personal GitHub Action with AI integration in just one hour? That’s right! In 2026, thanks to advancements in AI tools and GitHub’s ecosystem, it’s more straightforward than ever, even for solo founders.

Prerequisites: What You Need Before You Start

Before diving in, ensure you have the following:

  • GitHub Account: Free or Pro tier (Pro offers more features but isn’t necessary for this tutorial).
  • Node.js: Make sure you have Node.js installed (version 14 or later).
  • Basic Knowledge of JavaScript: Understanding the basics will help you navigate the coding part.
  • A Text Editor: Use something like VSCode, which is free and offers great support for JavaScript.

Step 1: Setting Up Your GitHub Repository

  1. Create a New Repository: Go to GitHub and create a new repository. Name it something relevant, like my-ai-action.
  2. Clone the Repository Locally: Use the command git clone <your-repo-url> to get a local copy.
  3. Navigate to the Directory: cd my-ai-action.

Step 2: Initialize Your GitHub Action

  1. Create the Action Metadata File: Inside your repository, create a new file called action.yml. This file will define your action’s inputs and outputs.

    name: 'My AI Action'
    description: 'A GitHub Action that uses AI to generate text.'
    inputs:
      input_text:
        description: 'Text to process'
        required: true
    runs:
      using: 'node12'
      main: 'index.js'
    
  2. Create the index.js File: This is where the magic happens. Create a file called index.js in your repository.

const core = require('@actions/core');
const { Configuration, OpenAI } = require('openai');

async function run() {
    try {
        const inputText = core.getInput('input_text');
        const configuration = new Configuration({
            apiKey: process.env.OPENAI_API_KEY,
        });
        const openai = new OpenAI(configuration);
        
        const response = await openai.createCompletion({
            model: 'text-davinci-003',
            prompt: inputText,
            max_tokens: 100,
        });
        
        core.setOutput('output_text', response.data.choices[0].text);
    } catch (error) {
        core.setFailed(error.message);
    }
}

run();

Step 3: Integrating AI

  1. Set Up OpenAI API: You’ll need an OpenAI account. As of May 2026, OpenAI offers a free tier with limited usage and paid plans starting at $20/month. Sign up and get your API key.

  2. Add Your API Key: In your GitHub repository, go to Settings > Secrets and add a new secret named OPENAI_API_KEY with your API key.

Step 4: Testing Your Action Locally

  1. Install Dependencies: Run npm init -y and then npm install @actions/core openai.

  2. Run Your Action: You can test your action locally using the act CLI tool, which simulates GitHub Actions locally. Install it and run:

    act -s OPENAI_API_KEY=<your-api-key>
    

Troubleshooting: Common Issues

  • API Key Issues: Ensure your API key is correct and has the necessary permissions.
  • Node Version: Make sure you’re using the correct version of Node.js.
  • Dependency Errors: Double-check that all required packages are installed.

What’s Next?

Now that you’ve built a personal GitHub Action, think about how you can expand its functionality. You could integrate other APIs, add more input options, or even publish it to the GitHub Marketplace for others to use.

Conclusion: Start Here

Building a personal GitHub Action with AI is not only feasible but also a valuable addition to your developer toolkit. If you’re looking to automate tasks or integrate AI capabilities into your projects, this is a great starting point.

In our experience, the combination of GitHub Actions and AI can save you countless hours on repetitive tasks, allowing you to focus on what really matters—building your product.

Follow Our Building Journey

Weekly podcast episodes on tools we're testing, products we're shipping, and lessons from building in public.

Subscribe

Never miss an episode

Subscribe to Built This Week for weekly insights on AI tools, product building, and startup lessons from Ryz Labs.

Subscribe
Ai Coding Tools

10 AI Coding Tools That Will Drastically Reduce Your Debugging Time

10 AI Coding Tools That Will Drastically Reduce Your Debugging Time As a developer, whether you're just starting out or have years of experience, debugging can feel like a neverend

Oct 16, 20265 min read
Ai Coding Tools

10 Common Mistakes When Integrating AI Coding Tools into Your Workflow

10 Common Mistakes When Integrating AI Coding Tools into Your Workflow As developers, we’re always on the lookout for ways to streamline our workflow and boost productivity. Enter

Oct 14, 20264 min read
Ai Coding Tools

5 Myths About AI Coding Tools That Could Hurt Your Development Process

5 Myths About AI Coding Tools That Could Hurt Your Development Process As a solo founder or indie hacker, you might be lured by the promises of AI coding tools that claim to simpli

Oct 13, 20264 min read
Ai Coding Tools

5 Common Mistakes Developers Make When Using AI Coding Tools in 2026

5 Common Mistakes Developers Make When Using AI Coding Tools in 2026 As AI coding tools have become an integral part of a developer's toolkit in 2026, many are still stumbling over

Oct 12, 20264 min read
Ai Coding Tools

5 Myths About AI Coding Tools: What Every Developer Should Know in 2026

5 Myths About AI Coding Tools: What Every Developer Should Know in 2026 As we dive into 2026, the landscape of AI coding tools has evolved significantly, yet many developers still

Oct 11, 20263 min read
Ai Coding Tools

Why AI Coding Assistants Are Overrated for Beginners in 2026

Why AI Coding Assistants Are Overrated for Beginners in 2026 As a solo founder or indie hacker, it’s tempting to think that AI coding assistants are the silver bullet to jumpstart

Oct 10, 20263 min read