Skip to content

Reply to issue comments #95

Reply to issue comments

Reply to issue comments #95

Workflow file for this run

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 -