Post

GitHub Actions & Artifical Intelligence

GitHub Actions & Artifical Intelligence

GitHub Actions

GitHub Actions have been a very enjoyable portion of my job for the past year or so. Working through a massive migration to GitHub, I have had a lot of time to play around with GitHub Actions and help educate engineers on its use case. If you’ve never used it, GitHub actions is a an automation platform (not just CI/CD!) within GitHub. Mostly, this takes a major role in building docker images, compiling executables, and things of the that nature. It runs via a locally installed application, typically run as a service. This application communicates back and forth with your GitHub instance (or the cloud) and is able to accept instruction files to execute steps. The beauty of GitHub actions is that it supports the ability to run any program present on the system. Including my favorite, PowerShell.

Actions & Scripting

Having the ability to run PowerShell gives massive flexibility to GitHub Actions when running it in a Windows Enviornment. If running on Linux, writing bash or Python scripts also works great. Something I’ve been putting a lot of time into (as is most of the world) is AI, and its use cases in business. Hosting our own LLM, an API could easily be spun up and configured for use within our enviornment. But a public cloud instance could also be useful, if you’re not sharing any sensitive data. While I experimented, I focused in on two particularly time consuming portions of my job as an automation team lead:

  • Documentation
  • Ensuring consistent coding guidelines

Documentation

Documentation is an extremely important, but painful part of working in IT. While I can’t get AI to write my documentation for my infrastructure (yet) I can feed it scripts, and allow it to give a pretty accurate breakdown of the script. Giving it proper instruction, the LLM should be capable of taking your script, translating it to a junior level, and providing code snippets along the way. A very valuable instruction is to ask the LLM to use mermaid diagrams, and provide the response with no extra text outside of the breakdown in markdown format. Using some git commands, you can compare your current commit against the previous commit of a branch, and then iterate through the changed files. This prevents the need to rebuild an entire knowledge base when one script is changed. Additionally, you can push to your .wiki portion of your repo, to automate the pushing of these changes to your GitHub wiki! An example of a prompt is below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#  Prompt for AI Agent – PowerShell Script Breakdown

You are an expert PowerShell mentor. Your task is to **break down and explain PowerShell scripts for junior developers** in a clear, structured, and beginner-friendly way.

Follow these rules when analyzing a script:

## 1. Format

* Always respond in **Markdown**.
* Use **headings, subheadings, bullet points, and numbered steps** for clarity.
* Show **inline code** for single commands (`Get-Process`).
* Use **fenced code blocks** for larger script snippets.
* Do not respond with any additional text, other than your review.
* Do not ask questions within your response.

## 2. Step-by-Step Walkthrough

* Break down the script **line by line or function by function**.
* For each part:

  * Show the code.
  * Explain what it does in **plain English**.
  * Explain **why it’s useful or important**.

## 3. Visualization with Mermaid

* Use **Mermaid flowcharts** to visualize script flow.
* Apply **colors** to make different elements stand out:

  * Start/End → Green
  * Functions/Modules → Purple
  * Decisions/Conditions → Yellow
  * Loops/Iterations → Blue
  * Errors/Exceptions → Red

### Mermaid Template

\`\`\`mermaid
flowchart TD
    A([Start]):::start --> B[Import Module]:::function
    B --> C{Check if File Exists?}:::decision
    C -->|Yes| D[Read File]:::process
    C -->|No| E[Throw Error]:::error
    D --> F([End]):::end
    E --> F

classDef start fill:#9fdf9f,stroke:#333,stroke-width:1px;
classDef end fill:#9fdf9f,stroke:#333,stroke-width:1px;
classDef function fill:#d0a9f5,stroke:#333,stroke-width:1px;
classDef decision fill:#f9f59f,stroke:#333,stroke-width:1px;
classDef process fill:#9fd7f9,stroke:#333,stroke-width:1px;
classDef error fill:#f59f9f,stroke:#333,stroke-width:1px;
\`\`\`

## 4. Explain Complex Concepts

* **Loops**: Explain what’s being iterated, and give a real-world analogy.
* **Functions**: Explain inputs, outputs, and purpose. Show how it’s called.
* **Pipelines**: Explain how data flows step by step.
* **Error Handling**: Explain what errors are caught and how they’re handled.

Style Guide Checking

Another great functonality that AI is good for, is checking code against a style guide. If setup correctly, you can have your style guide imported into your AI prompt, then feed your scripts into the prompt requesting it to reply with guidelines surrounding your updated scripts. This reponse could then be returned in a comment on the pull request using the GitHub API. Ideally, this would provide some degree of insight into any potential issues scripts have falling within your style guidelines. While this is by no means a perfect system, this offers a reliable way to at least get started with reviewing code, rather than needing to move line by line.

Closing Notes

These are just a few of the many possibilities out there for using GitHub Actions, and adding some extra support via AI. In the future, I’ll hopefully be able to include these YAML files in my response. However, they are created and used during my time at the company, so I am unable to share them directly.

This post is licensed under CC BY 4.0 by the author.