Skip to content

PR Comment Bot

PR Comment Bot #16579

name: PR Comment Bot
on:
workflow_run:
workflows: [PR Build]
jobs:
pr-comment-bot:
name: PR Comment Bot
runs-on: ubuntu-latest
steps:
- name: Check For Docs
id: check-for-docs
uses: actions/github-script@v6
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: '${{github.repository_owner}}',
repo: '${{ github.event.repository.name }}',
run_id: '${{github.event.workflow_run.id}}',
});
return !!artifacts.data.artifacts.find(artifact => artifact.name === 'docs');
- name: Get PR Event
id: get-pr-event
uses: potiuk/get-workflow-origin@v1_5
with:
token: ${{secrets.GITHUB_TOKEN}}
sourceRunId: ${{github.event.workflow_run.id}}
- name: Find Comment
id: find-comment
uses: peter-evans/find-comment@v2
with:
issue-number: ${{steps.get-pr-event.outputs.pullRequestNumber}}
comment-author: 'github-actions[bot]'
body-includes: 🤖 Clarity Release Bot
- name: Build Started PR Comment
if: ${{github.event.action == 'requested'}}
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{steps.find-comment.outputs.comment-id}}
issue-number: ${{steps.get-pr-event.outputs.pullRequestNumber}}
body: |
👋 @${{github.event.sender.login}},
* 🙏 The Clarity team thanks you for opening a pull request
* ⏳ The build for this PR has started
* 📫 I'll update this comment when the build has finished
Thank you,
🤖 Clarity Release Bot
edit-mode: replace
- name: Build Succeeded PR Comment
if: ${{github.event.workflow_run.conclusion == 'success'}}
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{steps.find-comment.outputs.comment-id}}
issue-number: ${{steps.get-pr-event.outputs.pullRequestNumber}}
body: |
👋 @${{github.event.sender.login}},
* 🙏 The Clarity team thanks you for opening a pull request
* 🎉 The build for this PR has succeeded
* 🔍 The PR is now ready for review
* 🍿 In the meantime, view a [preview of this PR](https://${{steps.get-pr-event.outputs.pullRequestNumber}}--${{secrets.NETLIFY_SITE_NAME}}.netlify.app)
* 🖐 You can always follow up here. If you're a VMware employee, you can also reach us on our [internal Clarity Support space](https://chat.google.com/room/AAAA5GLgPr4)
Thank you,
🤖 Clarity Release Bot
edit-mode: replace
- name: Build Failed with Docs Artifact PR Comment
if: ${{github.event.workflow_run.conclusion == 'failure' && steps.check-for-docs.outputs.result == 'true'}}
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{steps.find-comment.outputs.comment-id}}
issue-number: ${{steps.get-pr-event.outputs.pullRequestNumber}}
body: |
👋 @${{github.event.sender.login}},
* 😭 The build for this PR has failed
* 🗒 Please check out the [build log](${{github.event.workflow_run.html_url}})
* 🍿 Although the build failed, you can still view a [preview of this PR](https://${{steps.get-pr-event.outputs.pullRequestNumber}}--${{secrets.NETLIFY_SITE_NAME}}.netlify.app)
* 🖐 You can always follow up here. If you're a VMware employee, you can also reach us on our [internal Clarity Support space](https://chat.google.com/room/AAAA5GLgPr4)
Thank you,
🤖 Clarity Release Bot
edit-mode: replace
- name: Build Failed without Docs Artifact PR Comment
if: ${{github.event.workflow_run.conclusion == 'failure' && steps.check-for-docs.outputs.result == 'false'}}
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{steps.find-comment.outputs.comment-id}}
issue-number: ${{steps.get-pr-event.outputs.pullRequestNumber}}
body: |
👋 @${{github.event.sender.login}},
* 😭 The build for this PR has failed
* 🗒 Please check the [build log](${{github.event.workflow_run.html_url}})
* 🖐 You can always follow up here. If you're a VMware employee, you can also reach us on our [internal Clarity Support space](https://chat.google.com/room/AAAA5GLgPr4)
Thank you,
🤖 Clarity Release Bot
edit-mode: replace