Skip to content

Commit

Permalink
update comment
Browse files Browse the repository at this point in the history
  • Loading branch information
1ilsang committed Jun 7, 2024
1 parent e4d95ab commit 463fdde
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions .github/actions/netlify-preview/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ runs:
echo "NETLIFY_PREVIEW_URL=$NETLIFY_PREVIEW_URL" >> "$GITHUB_OUTPUT"
- name: Comment URL Preview on PR
# https://octokit.github.io/rest.js/v20
uses: actions/github-script@v7
env:
NETLIFY_PREVIEW_URL: ${{ steps.url-preview.outputs.NETLIFY_PREVIEW_URL }}
Expand All @@ -49,13 +50,26 @@ runs:
commit_sha: process.env.HEAD_COMMIT,
});
const issueNumber = result.data[0]?.number;
const commentId = false;
console.log(result.data[0]);
if (issueNumber) {
await github.rest.issues.createComment({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Preview URL: ${process.env.NETLIFY_PREVIEW_URL}`
});
if (commentId) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: commentId,
body: `Preview URL: ${process.env.NETLIFY_PREVIEW_URL}`
});
} else {
await github.rest.issues.createComment({
issue_number: issueNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Preview URL: ${process.env.NETLIFY_PREVIEW_URL}`
});
}
} else {
console.log('No PR found for commit ' + process.env.HEAD_COMMIT);
}
Expand Down

0 comments on commit 463fdde

Please sign in to comment.