@@ -2,39 +2,61 @@ name: Reply to issue comments
22on :
33 issue_comment :
44 types : [created]
5+
56permissions :
67 issues : write
8+
79jobs :
810 reply :
911 runs-on : ubuntu-latest
1012 if : contains(github.event.comment.body, '@njzjz-bot')
13+
1114 steps :
1215 - uses : actions/checkout@v6
16+
1317 - name : Extract identifiers
1418 id : extract-identifiers
19+ env :
20+ COMMENT_BODY : ${{ github.event.comment.body }}
21+ shell : bash
1522 run : |
16- echo identifiers=$(echo "${{ github.event.comment.body }}" | grep -oE '@njzjz-bot .*' | head -n1 | cut -c12- | xargs) >> $GITHUB_OUTPUT
23+ identifiers="$(
24+ printf '%s\n' "$COMMENT_BODY" \
25+ | grep -oE '@njzjz-bot .*' \
26+ | head -n1 \
27+ | cut -c12- \
28+ | xargs
29+ )"
30+ printf 'identifiers=%s\n' "$identifiers" >> "$GITHUB_OUTPUT"
31+
1732 - name : Run wenxian
1833 id : wenxian
1934 uses : ./
2035 with :
2136 id : ${{ steps.extract-identifiers.outputs.identifiers }}
37+
2238 - name : Prepare the comment body
2339 id : prepare-comment
40+ env :
41+ COMMENT_USER : ${{ github.event.comment.user.login }}
42+ IDENTIFIERS : ${{ steps.extract-identifiers.outputs.identifiers }}
43+ OUTPUT_BIBTEX : ${{ steps.wenxian.outputs.bibtex }}
44+ shell : bash
2445 run : |
2546 {
2647 echo 'comment<<EOF'
27- echo '@${{ github.event.comment.user.login }} Here is the BibTeX entry for `${{ steps.extract-identifiers.outputs.identifiers }}`:'
48+ printf '@%s Here is the BibTeX entry for `%s`:\n' "$COMMENT_USER" "$IDENTIFIERS"
2849 echo '```bibtex'
29- echo "${ OUTPUT_BIBTEX} "
50+ printf '%s\n' "$ OUTPUT_BIBTEX"
3051 echo '```'
31- echo EOF
32- } >> $GITHUB_OUTPUT
33- env :
34- OUTPUT_BIBTEX : ${{ steps.wenxian.outputs.bibtex }}
52+ echo 'EOF'
53+ } >> "$GITHUB_OUTPUT"
54+
3555 - name : Post comment
36- run : |
37- echo "${OUTPUT_COMMENT}" | gh issue comment ${{ github.event.issue.number }} --body-file -
3856 env :
3957 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4058 OUTPUT_COMMENT : ${{ steps.prepare-comment.outputs.comment }}
59+ ISSUE_NUMBER : ${{ github.event.issue.number }}
60+ shell : bash
61+ run : |
62+ printf '%s\n' "$OUTPUT_COMMENT" | gh issue comment "$ISSUE_NUMBER" --body-file -
0 commit comments