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 <"* ]]; 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 <")) | .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("")) | .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"