forked from tiann/hapi
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (76 loc) · 2.62 KB
/
issue-auto-response.yml
File metadata and controls
82 lines (76 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Issue Auto Response
on:
issues:
types: [opened, labeled]
concurrency:
group: issue-auto-response-${{ github.event.issue.number }}
cancel-in-progress: false
jobs:
auto-response:
if: |
!contains(github.event.issue.labels.*.name, 'duplicate') &&
!contains(github.event.issue.labels.*.name, 'spam') &&
!contains(github.event.issue.labels.*.name, 'bot-skip')
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: Check for existing HAPI Bot response
id: check_bot
uses: actions/github-script@v7
with:
script: |
const marker = "*HAPI Bot*";
const allowedLogins = (process.env.HAPI_BOT_LOGINS || "github-actions[bot]")
.split(",")
.map((value) => value.trim())
.filter(Boolean);
const comments = await github.paginate(
github.rest.issues.listComments,
{
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
per_page: 100
}
);
const hasBot = comments.some(
(comment) => {
if (!(comment?.body || "").includes(marker)) {
return false;
}
const user = comment.user;
if (!user || user.type !== "Bot") {
return false;
}
return allowedLogins.includes(user.login);
}
);
core.setOutput("has_bot", hasBot ? "true" : "false");
if (hasBot) {
core.info("Existing HAPI Bot response found; skipping.");
}
env:
HAPI_BOT_LOGINS: ${{ vars.HAPI_BOT_LOGINS }}
- name: Checkout repository
if: steps.check_bot.outputs.has_bot != 'true'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Codex for Issue Auto Response
if: steps.check_bot.outputs.has_bot != 'true'
uses: openai/codex-action@v1
env:
GH_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ github.token }}
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
responses-api-endpoint: ${{ secrets.OPENAI_BASE_URL }}
model: ${{ vars.OPENAI_MODEL || 'gpt-5.4' }}
effort: ${{ vars.OPENAI_EFFORT || 'high' }}
sandbox: danger-full-access
safety-strategy: drop-sudo
prompt-file: .github/prompts/issue-auto-response.md
allow-bots: true
allow-users: "*"