Skip to content

Commit

Permalink
Post updates to PR as well (#10)
Browse files Browse the repository at this point in the history
Signed-off-by: Russ Dias <[email protected]>
  • Loading branch information
russdias authored Jan 7, 2025
1 parent 262d9a6 commit abb2f1d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ on:

permissions:
contents: write
pull_requests: read

jobs:
deploy:
Expand Down
17 changes: 17 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions src/services/github.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import { GITHUB_TOKEN } from 'src/consts'
import { octoClient } from '../clients/octoClient'
Expand Down Expand Up @@ -26,4 +27,24 @@ export const postDeployUpdate = async (deploy: Deploy): Promise<void> => {
commit_sha: context.sha,
body: message
})

const { data: pullRequests } =
await octokit.rest.repos.listPullRequestsAssociatedWithCommit({
owner,
repo,
commit_sha: context.sha
})

if (pullRequests.length === 0) {
core.info('No pull requests associated with this commit.')
return
}

const prNumber = pullRequests[0].number
await octokit.rest.issues.createComment({
owner,
repo,
issue_number: prNumber,
body: message
})
}

2 comments on commit abb2f1d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸš€ Render Deployment Update

πŸ“Š Status: build_in_progress
⏰ Triggered at: 1/7/2025, 11:27:28 AM

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸš€ Render Deployment Update

πŸ“Š Status: live
⏰ Triggered at: 1/7/2025, 11:27:28 AM
πŸ”— Service URL: https://express-hello-world-4742.onrender.com

Please sign in to comment.