diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a0f133c..8a48048 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }}" diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml new file mode 100644 index 0000000..f2ee905 --- /dev/null +++ b/.github/workflows/test-action.yml @@ -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 }}" diff --git a/dist/index.js b/dist/index.js index 551dc48..5aea7a5 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29024,11 +29024,23 @@ async function run() { const owner = github_1.context.repo.owner; const repo = github_1.context.repo.repo; 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}`); } diff --git a/src/main.ts b/src/main.ts index 36aded8..78e5b60 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,11 +20,24 @@ export async function run(): Promise { 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) {