-
-
Notifications
You must be signed in to change notification settings - Fork 266
71 lines (60 loc) · 2.13 KB
/
wiki.yml
File metadata and controls
71 lines (60 loc) · 2.13 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
name: 'bitplatform wiki'
on:
issues:
types: [opened]
discussion:
types: [created]
jobs:
build-and-comment:
runs-on: ubuntu-latest
permissions:
issues: write
discussions: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Run wiki query script
id: run-mcp-query
run: |
chmod +x ./.github/workflows/wiki.sh
echo "wiki_url=$(./.github/workflows/wiki.sh)" >> $GITHUB_OUTPUT
env:
ISSUE_TITLE: ${{ github.event.issue.title || github.event.discussion.title }}
ISSUE_BODY: ${{ github.event.issue.body || github.event.discussion.body }}
- name: Write comment
if: steps.run-mcp-query.outputs.wiki_url
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const commentBody = `
Hello there! I'm a wiki 🤖.
Based on the content of this thread, I've found a potentially relevant wiki page for you!
**✨ [View Wiki Page](${{ steps.run-mcp-query.outputs.wiki_url }})**
I hope this helps!
`;
if (context.eventName === 'issues') {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
} else if (context.eventName === 'discussion') {
const discussionId = context.payload.discussion.node_id;
await github.graphql(
`mutation($discussionId: ID!, $body: String!) {
addDiscussionComment(input: {discussionId: $discussionId, body: $body}) {
comment {
id
}
}
}`,
{
discussionId: discussionId,
body: commentBody
}
);
}