Skip to content

Commit

Permalink
ci(gh): add comment when /build_test is finished (#745)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwangggg authored Feb 28, 2024
1 parent a552021 commit 6b2e997
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/test-ci-command.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,40 @@ jobs:
ref: ${{ needs.checkout-branch.outputs.PR_head_ref }}
tag: ${{ needs.get-test-image-tag.outputs.tag }}
sha: ${{ needs.checkout-branch.outputs.PR_head_sha }}

successful-test:
runs-on: ubuntu-latest
needs: [run-test-jobs]
permissions:
pull-requests: write
steps:
- name: Leave Actions Run Comment
uses: actions/github-script@v6
with:
script: |
const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`;
const commentBody = `\`/build_test\` completed successfully ✅. \n[View Actions Run](${runURL}).`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});
cancelled-test:
if: (always() && contains(needs.*.result, 'failure'))
runs-on: ubuntu-latest
needs: [run-test-jobs]
steps:
- name: Leave Actions Run Comment
uses: actions/github-script@v6
with:
script: |
const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`;
const commentBody = `\`/build_test\` : At least one test failed ❌. \n[View Actions Run](${runURL}).`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: commentBody
});

0 comments on commit 6b2e997

Please sign in to comment.