Skip to content

Fix CI and add review app comment #1

Fix CI and add review app comment

Fix CI and add review app comment #1

name: Comment Review App URL
on:
pull_request:
types: [opened, synchronize]
jobs:
comment:
runs-on: ubuntu-latest
steps:
- name: Comment PR with Review App URL
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
const reviewAppUrl = `https://kernelboard-pr-${prNumber}.herokuapp.com`;
// Check if we already commented
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const botComment = comments.data.find(c =>
c.body.includes('Review App Preview')
);
const body = `## 🔍 Review App Preview
Your preview deployment will be available at:
**${reviewAppUrl}**

Check failure on line 32 in .github/workflows/review-app-comment.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/review-app-comment.yml

Invalid workflow file

You have an error in your yaml syntax on line 32
> Note: The review app may take a few minutes to build and deploy after pushing.`;
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: body
});
}