mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-18 14:51:50 +02: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:
|
on:
|
||||||
issues:
|
issues:
|
||||||
types: [opened]
|
types: [opened]
|
||||||
|
issue_comment:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
@@ -12,6 +14,13 @@ permissions:
|
|||||||
jobs:
|
jobs:
|
||||||
ai_first_reply:
|
ai_first_reply:
|
||||||
runs-on: ubuntu-latest
|
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:
|
steps:
|
||||||
- name: Compose and post AI reply
|
- name: Compose and post AI reply
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
@@ -22,7 +31,7 @@ jobs:
|
|||||||
const issue = context.payload.issue;
|
const issue = context.payload.issue;
|
||||||
const { owner, repo } = context.repo;
|
const { owner, repo } = context.repo;
|
||||||
|
|
||||||
// Optionally pull README for a bit of repo context
|
// Optional repo context
|
||||||
let readmeText = '';
|
let readmeText = '';
|
||||||
try {
|
try {
|
||||||
const readme = await github.rest.repos.getReadme({ owner, repo });
|
const readme = await github.rest.repos.getReadme({ owner, repo });
|
||||||
@@ -84,7 +93,14 @@ jobs:
|
|||||||
ai_autofix_pr:
|
ai_autofix_pr:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: ai_first_reply
|
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:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@@ -154,9 +170,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
branch="ai/autofix-${{ github.event.issue.number }}"
|
|
||||||
patch="${{ steps.genpatch.outputs.result }}"
|
patch="${{ steps.genpatch.outputs.result }}"
|
||||||
|
|
||||||
if [ -z "$patch" ]; then
|
if [ -z "$patch" ]; then
|
||||||
echo "No patch produced; skipping PR."
|
echo "No patch produced; skipping PR."
|
||||||
echo "skip_pr=true" >> "$GITHUB_OUTPUT"
|
echo "skip_pr=true" >> "$GITHUB_OUTPUT"
|
||||||
@@ -164,29 +178,19 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$patch" > ai.patch
|
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 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"
|
echo "skip_pr=false" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Open PR
|
- name: Create Pull Request
|
||||||
if: steps.apply.outputs.skip_pr == 'false'
|
if: steps.apply.outputs.skip_pr == 'false'
|
||||||
uses: actions/github-script@v7
|
uses: peter-evans/create-pull-request@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
branch: ai/autofix-${{ github.event.issue.number }}
|
||||||
const { owner, repo } = context.repo;
|
title: AI autofix for #${{ github.event.issue.number }}
|
||||||
const head = `ai/autofix-${{ github.event.issue.number }}`;
|
commit-message: AI autofix for #${{ github.event.issue.number }}
|
||||||
await github.rest.pulls.create({
|
body: |
|
||||||
owner, repo,
|
This PR was generated automatically from issue #${{ github.event.issue.number }}.
|
||||||
head,
|
|
||||||
base: 'main',
|
Label `auto-pr` triggered patch creation. Please review carefully.
|
||||||
title: `AI autofix for #${{ github.event.issue.number }}`,
|
labels: auto-pr, ai-generated
|
||||||
body: `This PR was generated automatically from issue #${{ github.event.issue.number }}.
|
delete-branch: true
|
||||||
> Label \`auto-pr\` triggered patch creation. Please review carefully.`,
|
|
||||||
maintainer_can_modify: true
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user