140 lines
4.3 KiB
YAML
140 lines
4.3 KiB
YAML
name: duplicate-issues
|
|
|
|
on:
|
|
issues:
|
|
types: [opened, edited]
|
|
|
|
jobs:
|
|
check-duplicates:
|
|
if: github.event.action == 'opened'
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
permissions:
|
|
contents: read
|
|
issues: write
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Install opencode
|
|
run: curl -fsSL https://opencode.ai/install | bash
|
|
|
|
- name: Check duplicates and compliance
|
|
env:
|
|
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
OPENCODE_PERMISSION: |
|
|
{
|
|
"bash": "deny",
|
|
"webfetch": "deny",
|
|
"edit": "deny",
|
|
"write": "deny"
|
|
}
|
|
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
|
REPO: ${{ github.repository }}
|
|
run: |
|
|
ISSUE_TITLE=$(gh issue view "$ISSUE_NUMBER" --repo "$REPO" --json title --jq .title)
|
|
ISSUE_BODY=$(gh issue view "$ISSUE_NUMBER" --repo "$REPO" --json body --jq .body)
|
|
|
|
PROMPT=$(cat <<EOF
|
|
Check this new issue for compliance and duplicates:
|
|
|
|
CURRENT_ISSUE_NUMBER: $ISSUE_NUMBER
|
|
|
|
Title: $ISSUE_TITLE
|
|
|
|
Description:
|
|
$ISSUE_BODY
|
|
EOF
|
|
)
|
|
|
|
COMMENT=$(opencode run --agent duplicate-issue "$PROMPT")
|
|
|
|
if [ "$COMMENT" = "No action required" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
BODY="_The following comment was made by an LLM, it may be inaccurate:_
|
|
|
|
$COMMENT"
|
|
|
|
gh issue comment "$ISSUE_NUMBER" --repo "$REPO" --body "$BODY"
|
|
|
|
if [[ "$COMMENT" == *"<!-- issue-compliance -->"* ]]; then
|
|
gh issue edit "$ISSUE_NUMBER" --repo "$REPO" --add-label needs:compliance
|
|
fi
|
|
|
|
recheck-compliance:
|
|
if: github.event.action == 'edited' && contains(github.event.issue.labels.*.name, 'needs:compliance')
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
permissions:
|
|
contents: read
|
|
issues: write
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Install opencode
|
|
run: curl -fsSL https://opencode.ai/install | bash
|
|
|
|
- name: Recheck compliance
|
|
env:
|
|
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
OPENCODE_PERMISSION: |
|
|
{
|
|
"bash": "deny",
|
|
"webfetch": "deny",
|
|
"edit": "deny",
|
|
"write": "deny"
|
|
}
|
|
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
|
REPO: ${{ github.repository }}
|
|
run: |
|
|
ISSUE_TITLE=$(gh issue view "$ISSUE_NUMBER" --repo "$REPO" --json title --jq .title)
|
|
ISSUE_BODY=$(gh issue view "$ISSUE_NUMBER" --repo "$REPO" --json body --jq .body)
|
|
|
|
PROMPT=$(cat <<EOF
|
|
Recheck this edited issue for compliance:
|
|
|
|
MODE: recheck-compliance
|
|
CURRENT_ISSUE_NUMBER: $ISSUE_NUMBER
|
|
|
|
Title: $ISSUE_TITLE
|
|
|
|
Description:
|
|
$ISSUE_BODY
|
|
EOF
|
|
)
|
|
|
|
COMMENT=$(opencode run --agent duplicate-issue "$PROMPT")
|
|
|
|
if [ "$COMMENT" = "No action required" ]; then
|
|
gh issue edit "$ISSUE_NUMBER" --repo "$REPO" --remove-label needs:compliance || true
|
|
|
|
IDS=$(gh api "repos/$REPO/issues/$ISSUE_NUMBER/comments" --jq '.[] | select(.body | contains("<!-- issue-compliance -->")) | .id')
|
|
for id in $IDS; do
|
|
gh api -X DELETE "repos/$REPO/issues/comments/$id"
|
|
done
|
|
|
|
gh issue comment "$ISSUE_NUMBER" --repo "$REPO" --body "Thanks for updating your issue. It now meets our contributing guidelines. :+1:"
|
|
exit 0
|
|
fi
|
|
|
|
gh issue edit "$ISSUE_NUMBER" --repo "$REPO" --add-label needs:compliance
|
|
|
|
BODY="_The following comment was made by an LLM, it may be inaccurate:_
|
|
|
|
$COMMENT"
|
|
|
|
EXISTING=$(gh api "repos/$REPO/issues/$ISSUE_NUMBER/comments" --jq '[.[] | select(.body | contains("<!-- issue-compliance -->")) | .id] | last // empty')
|
|
if [ -n "$EXISTING" ]; then
|
|
gh api -X PATCH "repos/$REPO/issues/comments/$EXISTING" -f body="$BODY"
|
|
exit 0
|
|
fi
|
|
|
|
gh issue comment "$ISSUE_NUMBER" --repo "$REPO" --body "$BODY"
|