-
Notifications
You must be signed in to change notification settings - Fork 7
62 lines (55 loc) · 1.74 KB
/
Copy pathcomment.yaml
File metadata and controls
62 lines (55 loc) · 1.74 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
name: Reply to issue comments
on:
issue_comment:
types: [created]
permissions:
issues: write
jobs:
reply:
runs-on: ubuntu-latest
if: contains(github.event.comment.body, '@njzjz-bot')
steps:
- uses: actions/checkout@v6
- name: Extract identifiers
id: extract-identifiers
env:
COMMENT_BODY: ${{ github.event.comment.body }}
shell: bash
run: |
identifiers="$(
printf '%s\n' "$COMMENT_BODY" \
| grep -oE '@njzjz-bot .*' \
| head -n1 \
| cut -c12- \
| xargs
)"
printf 'identifiers=%s\n' "$identifiers" >> "$GITHUB_OUTPUT"
- name: Run wenxian
id: wenxian
uses: ./
with:
id: ${{ steps.extract-identifiers.outputs.identifiers }}
- name: Prepare the comment body
id: prepare-comment
env:
COMMENT_USER: ${{ github.event.comment.user.login }}
IDENTIFIERS: ${{ steps.extract-identifiers.outputs.identifiers }}
OUTPUT_BIBTEX: ${{ steps.wenxian.outputs.bibtex }}
shell: bash
run: |
{
echo 'comment<<EOF'
printf '@%s Here is the BibTeX entry for `%s`:\n' "$COMMENT_USER" "$IDENTIFIERS"
echo '```bibtex'
printf '%s\n' "$OUTPUT_BIBTEX"
echo '```'
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Post comment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OUTPUT_COMMENT: ${{ steps.prepare-comment.outputs.comment }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
shell: bash
run: |
printf '%s\n' "$OUTPUT_COMMENT" | gh issue comment "$ISSUE_NUMBER" --body-file -