How to Build a Personal GitHub Action with AI in Just 1 Hour
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
- Create a New Repository: Go to GitHub and create a new repository. Name it something relevant, like
my-ai-action. - Clone the Repository Locally: Use the command
git clone <your-repo-url>to get a local copy. - Navigate to the Directory:
cd my-ai-action.
Step 2: Initialize Your GitHub Action
-
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' -
Create the
index.jsFile: This is where the magic happens. Create a file calledindex.jsin 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
-
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.
-
Add Your API Key: In your GitHub repository, go to Settings > Secrets and add a new secret named
OPENAI_API_KEYwith your API key.
Step 4: Testing Your Action Locally
-
Install Dependencies: Run
npm init -yand thennpm install @actions/core openai. -
Run Your Action: You can test your action locally using the
actCLI 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.