Automate Projects with AI: Integrate GitHub Models in Actions Workflows This title highlights the key point of the content, which is automating projects using GitHub Models in Actions workflows. The use of "automate" and "integrate" conveys the process of combining these tools to improve workflows. Additionally, "AI" emphasizes the use of artificial intelligence in the GitHub Models, making the title more informative and engaging.

GitHub Models brings AI into GitHub Actions workflows, enabling automation of triage and summarization tasks. To use GitHub Models, you need to grant your workflow access to AI models by adding the 'models: read' permission. This article presents three ways to integrate and automate the use of GitHub Models in GitHub Actions workflows.

The first example demonstrates how to use the AI inference action to request more information in bug reports. By creating a workflow that triggers when a new issue is opened, you can automatically check if the bug report has enough information to be actionable and respond if it doesn't. This can save time and reduce the number of back-and-forth communications necessary to gather needed information.

The second example uses the gh CLI with the gh-models extension to create release notes from merged pull requests. This workflow triggers when a pull request is closed and merged and uses the GitHub CLI to gather information and take action, including calling models to summarize the merged pull requests and add them to a release notes issue. This automation can help save time and energy for developers.

The third example combines the use of the GitHub CLI with the gh-models extension and a prompt file to automate a more complex, scheduled workflow. This workflow triggers every Monday at 9 a.m. and creates a weekly issue to summarize, thematize, and prioritize newly opened issues, helping keep track of activity and issues in a growing project.

Automate your project with GitHub Models in Actions

Kevin Lewis

Contents

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

Related posts