name: duplicate-issues on: issues: types: [opened] jobs: check-duplicates: runs-on: blacksmith-4vcpu-ubuntu-2404 permissions: contents: read issues: write steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 1 - uses: ./.github/actions/setup-bun - name: Install dependencies run: bun install - name: Install opencode run: curl -fsSL https://opencode.ai/install | bash - name: Build prompt uses: actions/github-script@v8 with: script: | const fs = require("fs") const issue = context.payload.issue const body = issue.body ?? "" const text = [ "Check this new issue for compliance and duplicates:", "", `CURRENT_ISSUE_NUMBER: ${issue.number}`, "", `Title: ${issue.title}`, "", "Description:", body, ].join("\n") fs.writeFileSync("issue_info.txt", text) - name: Check duplicates and compliance env: OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | bun script/duplicate-issue.ts -f issue_info.txt "Check the attached file for issue details and return either a comment body or No action required" > issue_comment.txt - name: Post comment and label issue env: COMMENT: ${{ github.workspace }}/issue_comment.txt uses: actions/github-script@v8 with: script: | const fs = require("fs") const comment = fs.readFileSync(process.env.COMMENT, "utf8").trim() if (comment === "No action required") { core.info("No comment needed") return } await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.payload.issue.number, body: `_The following comment was made by an LLM, it may be inaccurate:_\n\n${comment}`, }) if (!comment.includes("")) return await github.rest.issues.addLabels({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.payload.issue.number, labels: ["needs:compliance"], })