Skip to content

Commit

Permalink
build: rewrite as GitHub client script and include full quote for unk…
Browse files Browse the repository at this point in the history
…nown commands

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---

---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
  - task: run_javascript_examples
    status: na
  - task: run_c_examples
    status: na
  - task: run_cpp_examples
    status: na
  - task: run_javascript_readme_examples
    status: na
  - task: run_c_benchmarks
    status: passed
  - task: run_cpp_benchmarks
    status: na
  - task: run_fortran_benchmarks
    status: na
  - task: run_javascript_benchmarks
    status: na
  - task: run_julia_benchmarks
    status: na
  - task: run_python_benchmarks
    status: na
  - task: run_r_benchmarks
    status: na
  - task: run_javascript_tests
    status: passed
---
  • Loading branch information
Planeshifter committed Jan 25, 2025
1 parent 3446619 commit 57300ef
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions .github/workflows/slash_commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,33 @@ jobs:
# Add initial reaction to comment with slash command:
- name: 'Add initial reaction'
run: |
COMMENT="${{ github.event.comment.body }}"
if [[ $COMMENT =~ ^/stdlib\ (help|check-files|update-copyright-years|lint-autofix|merge|rebase) ]]; then
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions" \
-d '{"content":"eyes"}'
else
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/comments" \
-d '{"body":"@${{ github.event.comment.user.login }}, slash command not recognized. Please use `/stdlib help` to view available commands."}'
fi
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}
script: |
const commentBody = github.event.comment.body.trim();
const RE_COMMANDS = /^\/stdlib\s+(help|check-files|update-copyright-years|lint-autofix|merge|rebase)$/i;
const isRecognizedCommand = RE_COMMANDS.test( commentBody );
if ( isRecognizedCommand ) {
await github.rest.reactions.createForIssueComment({
'owner': context.repo.owner,
'repo': context.repo.repo,
'comment_id': github.event.comment.id,
'content': 'eyes'
});
} else {
// Include the full user comment as a Markdown quote block in response:
const lines = commentBody.split( '\n' );
const quote = lines.map( line => `> ${line}` ).join( '\n' );
await github.rest.issues.createComment({
'owner': context.repo.owner,
'repo': context.repo.repo,
'issue_number': github.event.issue.number,
'body': `${quote}\n\n@${github.event.comment.user.login}, slash command not recognized. Please use \`/stdlib help\` to view available commands.`
});
}
# Define a job for checking for required files:
check_files:
Expand Down

0 comments on commit 57300ef

Please sign in to comment.