Automate your project with GitHub Models in Actions
Kevin Lewis
Contents
- GitHub Models brings AI into your GitHub Actions workflows
- Add the right permissions
- Security tip
- Example one: Request more information in bug reports
- Example two: Creating release notes from merged pull requests
- Example three: summarizing and prioritizing issues
- Conclusion
- Tags
- Written by
- Related posts
- Explore more from GitHub
- Customer stories
- GitHub Universe 2025
- We do newsletters, too
GitHub Models brings AI into your GitHub Actions workflows
GitHub Models helps you automate triage, summarize, and more — right where your project lives.
Add the right permissions
Before you can use GitHub Models in your Actions workflows, you need to grant your workflow access to AI models.
permissions:
contents: read
issues: write
models: read
Security tip
Give GitHub Actions workflows the minimum permissions that are required to perform the actions. This minimizes the chance of a malicious actor opening an issue and instructing a model to do something you don't want.
Example one: Request more information in bug reports
This example will show you how to use the AI inference action and how to use AI to create branching logic.
You can find the full workflow in this repo.
name: Bug Report Reproduction Check
on:
issues:
types: [opened]
permissions:
contents: read
issues: write
models: read
jobs:
reproduction-steps-check:
runs-on: ubuntu-latest
steps:
- name: Fetch Issue
id: issue
uses: actions/github-script@v7
with:
script: |
const issue = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
})
core.setOutput('title', issue.data.title)
core.setOutput('body', issue.data.body)
- name: Analyze Issue For Reproduction
if: contains(join(github.event.issue.labels.*.name, ','), 'bug')
id: analyze-issue
uses: actions/ai-inference@v1
with:
model: mistral-ai/ministral-3b
system-prompt: |
Given a bug report title and text for an application, return 'pass' if there is enough information to reliably reproduce the issue, meaning the report clearly describes the steps to reproduce the problem, specifies the expected and actual behavior, and includes environment details such as browser and operating system; if any of these elements are missing or unclear, return a brief description of what is missing in a friendly response to the author instead of 'pass'. Consider the following title and body:
prompt: |
Title: ${{ steps.issue.outputs.title }}
Body: ${{ steps.issue.outputs.body }}
- name: Comment On Issue
if: contains(join(github.event.issue.labels.*.name, ','), 'bug') && steps.analyze-issue.outputs.response != 'pass'
uses: actions/github-script@v7
env:
AI_RESPONSE: steps.analyze-issue.outputs.response
with:
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: process.env.AI_RESPONSE
})
Example two: Creating release notes from merged pull requests
You can trigger GitHub Actions workflow steps when pull requests are merged and use the GitHub CLI to gather information and take action, including calling models.
You can find the full workflow in this repo.
name: Add to Changelog
on:
pull_request:
types:
- closed
permissions:
pull-requests: read
issues: write
contents: read
models: read
jobs:
add_to_changelog:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install gh-models extension
run: gh extension install https://github.com/github/gh-models
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Summarize pull request and append to release issue
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |-
PR_NUMBER="${{ github.event.pull_request.number }}"
gh pr view "$PR_NUMBER" --json title,body,comments,reviews > pr.json
cat pr.json | gh models run xai/grok-3-mini \
"Given the following pull request information, generate a single, clear, and concise one-line changelog entry that summarizes the main change (feature, fix, or bug) introduced by this PR. Use neutral, user-facing language and avoid technical jargon or internal references. Only write the line, with no additional introduction or explanation text." > summary.md
gh issue list --label release --limit 1 --json number --jq '.[0].number' > release_issue.txt
mv release_issue.txt release_issue.md
cat summary.md >> release_issue.md
gh issue edit "${(cat release_issue.md)}" --body "$(cat release_issue.md)"
Example three: summarizing and prioritizing issues
To open a weekly issue to summarize, thematize, and prioritize newly opened issues, you can trigger GitHub Actions on a schedule.
You can find the full workflow and prompt files in this repo.
name: Weekly Issue Summary
on:
workflow_dispatch:
schedule:
- cron: '0 9 * * 1'
permissions:
issues: write
contents: read
models: read
jobs:
create_weekly_summary:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install gh-models extension
run: gh extension install https://github.com/github/gh-models
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get issues from the past week and summarize
id: get_issues
run: |-
LAST_WEEK=$(date -d "7 days ago" +"%Y-%m-%d")
gh search issues "created:>$LAST_WEEK" --state=open --json title,body,url --repo ${{ github.repository }} > issues.json
cat issues.json | gh models run --file prompts/issue-summary.prompt.yml > summary.md
- name: Create Issue Summary
uses: actions/github-script@v7
with:
script: |
gh issue create --title "Weekly Issue Summary $(date -d '7 days ago' '+%B %d') to $(date '+%B %d')" --label summary --body-file summary.md
Conclusion
Whether you start simple with the AI inference action, use the gh-models CLI with inline prompts, or create full-featured, prompt-driven workflows, GitHub Models makes it easy to scale your processes with AI.
Tags
- automation
- GitHub Actions
- GitHub Models
Written by
Senior Developer Advocate