Skip to content

Commit 431146b

Browse files
committed
build: leave comment when slash command fails
--- 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 ---
1 parent 2dbc10d commit 431146b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

.github/workflows/slash_commands.yml

+19
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,25 @@ jobs:
246246
247247
# Define the job's steps:
248248
steps:
249+
# Check if any previous job failed and post a comment:
250+
- name: 'Notify of command failure'
251+
if: |
252+
contains(needs.*.result, 'failure')
253+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
254+
with:
255+
github-token: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}
256+
script: |
257+
const commentBody = context.payload.comment.body.trim();
258+
const lines = commentBody.split( '\n' );
259+
const quote = lines.map( line => `> ${line}` ).join( '\n' );
260+
261+
await github.rest.issues.createComment({
262+
'owner': context.repo.owner,
263+
'repo': context.repo.repo,
264+
'issue_number': context.issue.number,
265+
'body': `${quote}\n\n@${context.payload.comment.user.login}, the slash command failed to complete. Please check the workflow logs for details.\n\n[View workflow run](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`
266+
});
267+
249268
- name: Remove in-progress label
250269
# Run the step regardless of the outcome of previous steps:
251270
if: always()

0 commit comments

Comments
 (0)