mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-10 09:51:02 +01:00
Update ai-triage.yml
This commit is contained in:
54
.github/workflows/ai-triage.yml
vendored
54
.github/workflows/ai-triage.yml
vendored
@@ -3,6 +3,8 @@ name: AI triage (comment + optional PR)
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -12,6 +14,13 @@ permissions:
|
||||
jobs:
|
||||
ai_first_reply:
|
||||
runs-on: ubuntu-latest
|
||||
# Run when: issue opened OR a '/codex' comment on an issue (not PR)
|
||||
if: >
|
||||
github.event_name == 'issues' ||
|
||||
(github.event_name == 'issue_comment' &&
|
||||
github.event.action == 'created' &&
|
||||
github.event.comment.body == '/codex' &&
|
||||
github.event.issue.pull_request == null)
|
||||
steps:
|
||||
- name: Compose and post AI reply
|
||||
uses: actions/github-script@v7
|
||||
@@ -22,7 +31,7 @@ jobs:
|
||||
const issue = context.payload.issue;
|
||||
const { owner, repo } = context.repo;
|
||||
|
||||
// Optionally pull README for a bit of repo context
|
||||
// Optional repo context
|
||||
let readmeText = '';
|
||||
try {
|
||||
const readme = await github.rest.repos.getReadme({ owner, repo });
|
||||
@@ -84,7 +93,14 @@ jobs:
|
||||
ai_autofix_pr:
|
||||
runs-on: ubuntu-latest
|
||||
needs: ai_first_reply
|
||||
if: ${{ contains(github.event.issue.labels.*.name, 'auto-pr') }}
|
||||
# Same trigger conditions as above AND issue has label 'auto-pr'
|
||||
if: >
|
||||
(github.event_name == 'issues' ||
|
||||
(github.event_name == 'issue_comment' &&
|
||||
github.event.action == 'created' &&
|
||||
github.event.comment.body == '/codex' &&
|
||||
github.event.issue.pull_request == null))
|
||||
&& contains(github.event.issue.labels.*.name, 'auto-pr')
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
@@ -154,9 +170,7 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
branch="ai/autofix-${{ github.event.issue.number }}"
|
||||
patch="${{ steps.genpatch.outputs.result }}"
|
||||
|
||||
if [ -z "$patch" ]; then
|
||||
echo "No patch produced; skipping PR."
|
||||
echo "skip_pr=true" >> "$GITHUB_OUTPUT"
|
||||
@@ -164,29 +178,19 @@ jobs:
|
||||
fi
|
||||
|
||||
echo "$patch" > ai.patch
|
||||
|
||||
git config user.name "ai-triage-bot"
|
||||
git config user.email "ai-triage-bot@users.noreply.github.com"
|
||||
git checkout -b "$branch"
|
||||
git apply --whitespace=fix ai.patch
|
||||
git add -A
|
||||
git commit -m "AI autofix for #${{ github.event.issue.number }}"
|
||||
git push -u origin "$branch"
|
||||
echo "skip_pr=false" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Open PR
|
||||
- name: Create Pull Request
|
||||
if: steps.apply.outputs.skip_pr == 'false'
|
||||
uses: actions/github-script@v7
|
||||
uses: peter-evans/create-pull-request@v7
|
||||
with:
|
||||
script: |
|
||||
const { owner, repo } = context.repo;
|
||||
const head = `ai/autofix-${{ github.event.issue.number }}`;
|
||||
await github.rest.pulls.create({
|
||||
owner, repo,
|
||||
head,
|
||||
base: 'main',
|
||||
title: `AI autofix for #${{ github.event.issue.number }}`,
|
||||
body: `This PR was generated automatically from issue #${{ github.event.issue.number }}.
|
||||
> Label \`auto-pr\` triggered patch creation. Please review carefully.`,
|
||||
maintainer_can_modify: true
|
||||
});
|
||||
branch: ai/autofix-${{ github.event.issue.number }}
|
||||
title: AI autofix for #${{ github.event.issue.number }}
|
||||
commit-message: AI autofix for #${{ github.event.issue.number }}
|
||||
body: |
|
||||
This PR was generated automatically from issue #${{ github.event.issue.number }}.
|
||||
|
||||
Label `auto-pr` triggered patch creation. Please review carefully.
|
||||
labels: auto-pr, ai-generated
|
||||
delete-branch: true
|
||||
|
||||
Reference in New Issue
Block a user