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

The 5 Best AI Coding Tools for Bootstrapped Founders in 2026

The 5 Best AI Coding Tools for Bootstrapped Founders in 2026 As a bootstrapped founder, you know that time and resources are limited. Finding ways to code faster and more efficient

May 8, 20264 min read
Ai Coding Tools

How to Write JavaScript Code in 30 Minutes Using AI Tools

How to Write JavaScript Code in 30 Minutes Using AI Tools If you're a beginner looking to write JavaScript code quickly, the idea of doing it in just 30 minutes may sound like a st

May 8, 20264 min read
Ai Coding Tools

Why GitHub Copilot is Overrated for Beginners (And What to Use Instead)

Why GitHub Copilot is Overrated for Beginners (And What to Use Instead) As a beginner coder, diving into the world of programming can feel overwhelming. You hear about all these am

May 8, 20264 min read
Ai Coding Tools

How to Use GitHub Copilot to Boost Productivity in One Hour

How to Use GitHub Copilot to Boost Productivity in One Hour As a solo founder or indie hacker, time is your most precious resource. You’ve probably heard the buzz about AI tools li

May 7, 20263 min read
Ai Coding Tools

How to Bootstrap Your First App Using AI Coding Tools in Just 14 Days

How to Bootstrap Your First App Using AI Coding Tools in Just 14 Days Bootstrapping your first app can feel like a daunting task, especially if you’re not a seasoned developer. But

May 7, 20265 min read
Ai Coding Tools

10 Mistakes That New Developers Make with AI Coding Tools

10 Mistakes That New Developers Make with AI Coding Tools As a new developer diving into the world of AI coding tools, it’s easy to get swept up in the excitement. However, many of

May 7, 20265 min read