Skip to content

Commit

Permalink
Add some logging
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyhs committed Jul 4, 2023
1 parent 61b186f commit 975ce69
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/comment-upserter.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as core from '@actions/core'
import {RestEndpointMethods} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/method-types.d'

import {MentionRule} from './configuration'
Expand Down Expand Up @@ -49,20 +50,26 @@ export class CommentUpserterImpl implements CommentUpserter {

if (existingComment === undefined) {
if (rules.length > 0) {
core.info('Creating a pull request comment')
await issuesApi.createComment({
owner: repo.owner,
repo: repo.repo,
issue_number: pullNumber,
body: commentBody
})
} else {
core.info('Not creating a pull request comment. No rules matched.')
}
} else if (existingComment.body !== commentBody) {
core.info('Updating pull request comment')
await issuesApi.updateComment({
owner: repo.owner,
repo: repo.repo,
comment_id: existingComment.id,
body: commentBody
})
} else {
core.info('Not updating pull request comment. Comment body matched.')
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/configuration-reader.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as core from '@actions/core'
import {RestEndpointMethods} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/method-types.d'
import * as yaml from 'js-yaml'

Expand Down Expand Up @@ -26,6 +27,7 @@ export class ConfigurationReaderImpl implements ConfigurationReader {

/** @override */
async read(repo: Repo, ref: string): Promise<Configuration> {
core.debug(`Reading codemention.yml on ${ref}`)
const {data} = await this.octokitRest.repos.getContent({
owner: repo.owner,
repo: repo.repo,
Expand Down
5 changes: 4 additions & 1 deletion src/files-changed-reader.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as core from '@actions/core'
import {RestEndpointMethods} from '@octokit/plugin-rest-endpoint-methods/dist-types/generated/method-types.d'
import parseDiff from 'parse-diff'

Expand Down Expand Up @@ -44,6 +45,8 @@ export class FilesChangedReaderImpl implements FilesChangedReader {
}
}
filesChanged.delete('/dev/null')
return [...filesChanged]
const result = [...filesChanged]
core.debug(`Files changed: ${result}`)
return result
}
}
2 changes: 2 additions & 0 deletions src/runner.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as core from '@actions/core'
import {Context} from '@actions/github/lib/context'
import {PullRequestEvent} from '@octokit/webhooks-types/schema.d'
import micromatch from 'micromatch'
Expand Down Expand Up @@ -31,6 +32,7 @@ export default class Runner {
const event = context.payload as PullRequestEvent
const pullRequest = event.pull_request
if (pullRequest.draft) {
core.debug('Skipping draft pull request')
return
}

Expand Down

0 comments on commit 975ce69

Please sign in to comment.