@@ -59,21 +59,33 @@ jobs:
5959
6060 # Add initial reaction to comment with slash command:
6161 - name : ' Add initial reaction'
62- run : |
63- COMMENT="${{ github.event.comment.body }}"
64- if [[ $COMMENT =~ ^/stdlib\ (help|check-files|update-copyright-years|lint-autofix|merge|rebase) ]]; then
65- curl -X POST \
66- -H "Accept: application/vnd.github.v3+json" \
67- -H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" \
68- "https://api.github.com/repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions" \
69- -d '{"content":"eyes"}'
70- else
71- curl -X POST \
72- -H "Accept: application/vnd.github.v3+json" \
73- -H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" \
74- "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \
75- -d '{"body":"@${{ github.event.comment.user.login }}, slash command not recognized. Please use `/stdlib help` to view available commands."}'
76- fi
62+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
63+ with :
64+ github-token : ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}
65+ script : |
66+ const commentBody = github.event.comment.body.trim();
67+ const RE_COMMANDS = /^\/stdlib\s+(help|check-files|update-copyright-years|lint-autofix|merge|rebase)$/i;
68+ const isRecognizedCommand = RE_COMMANDS.test( commentBody );
69+
70+ if ( isRecognizedCommand ) {
71+ await github.rest.reactions.createForIssueComment({
72+ 'owner': context.repo.owner,
73+ 'repo': context.repo.repo,
74+ 'comment_id': github.event.comment.id,
75+ 'content': 'eyes'
76+ });
77+ } else {
78+ // Include the full user comment as a Markdown quote block in response:
79+ const lines = commentBody.split( '\n' );
80+ const quote = lines.map( line => `> ${line}` ).join( '\n' );
81+
82+ await github.rest.issues.createComment({
83+ 'owner': context.repo.owner,
84+ 'repo': context.repo.repo,
85+ 'issue_number': github.event.issue.number,
86+ 'body': `${quote}\n\n@${github.event.comment.user.login}, slash command not recognized. Please use \`/stdlib help\` to view available commands.`
87+ });
88+ }
7789
7890 # Define a job for checking for required files:
7991 check_files :
0 commit comments