Skip to content

Commit

Permalink
Merge pull request #6 from tnyo43/count-comments
Browse files Browse the repository at this point in the history
Count comments and post messages
  • Loading branch information
tnyo43 committed Mar 2, 2024
2 parents 9cdb992 + b86dd4a commit 38598c1
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 20 deletions.
18 changes: 0 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,3 @@ jobs:
- run: pnpm run format:check
- run: pnpm run lint
- run: pnpm run test

test-action:
name: GitHub Actions Test
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
id: test-action
uses: ./

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
27 changes: 27 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
pull_request_review_comment:
types: [created]
issue_comment:
types: [created]

permissions:
contents: read

jobs:
test-action:
name: GitHub Actions Test
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
id: test-action
uses: ./

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
14 changes: 13 additions & 1 deletion dist/index.js

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

15 changes: 14 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,24 @@ export async function run(): Promise<void> {

core.debug(`owner: ${owner}, repo: ${repo}, PR #${pullRequest.number}`)

const comments = await octokit.rest.issues.listComments({
owner,
repo,
issue_number: pullRequest.number
})
const reviewComments = await octokit.rest.pulls.listReviewComments({
owner,
repo,
pull_number: pullRequest.number
})

await octokit.rest.issues.createComment({
owner,
repo,
issue_number: pullRequest.number,
body: 'Hello, this is my action!'
body: `the number of the comments is ${comments.data.length}\ncontents: \n${comments.data.map(c => `- ${c.user?.name}, ${c.body}`).join('\n')}
the number of the review comments is ${reviewComments.data.length}\ncontents: \n${reviewComments.data.map(c => `- ${c.user?.name}, ${c.body}`).join('\n')}`
})
core.debug(`Commented on PR #${pullRequest.number}`)
} catch (error) {
Expand Down

0 comments on commit 38598c1

Please sign in to comment.