Skip to content

Commit

Permalink
Test payload
Browse files Browse the repository at this point in the history
  • Loading branch information
rehlma committed Apr 12, 2024
1 parent 0aa3517 commit 5742078
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
23 changes: 14 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29018,20 +29018,25 @@ function run() {
try {
const token = core.getInput('token');
const octokit = github.getOctokit(token);
const payload = github.context.payload;
if (payload) {
console.log(JSON.stringify(payload));
return;
}
const editIssueId = core.getInput('edit-issue-id');
if (editIssueId) {
console.log('Edit issue id:', editIssueId);
return;
}
const pr = github.context.payload.pull_request;
if (!pr) {
throw new Error('This action can only be run on pull requests');
}
const prDiff = yield getPrDiff(octokit, pr.base.sha, pr.head.sha);
const todos = findTodos(prDiff);
console.log('Todos:', JSON.stringify(todos));
const useOutput = core.getInput('use-output');
yield commentPr(octokit, pr.number, todos);
// const pr = github.context.payload.pull_request
// if (!pr) {
// throw new Error('This action can only be run on pull requests')
// }
// const prDiff = await getPrDiff(octokit, pr.base.sha, pr.head.sha)
// const todos = findTodos(prDiff)
// console.log('Todos:', JSON.stringify(todos))
// const useOutput = core.getInput('use-output')
// await commentPr(octokit, pr.number, todos)
}
catch (error) {
if (error instanceof Error) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

25 changes: 15 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import { PrDiff, Todo, InnerTodo } from './types'
import { start } from 'repl'

export async function run(): Promise<void> {
try {
const token = core.getInput('token')
const octokit = github.getOctokit(token)

Check failure on line 8 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'octokit' is assigned a value but never used

Check failure on line 8 in src/main.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'octokit' is assigned a value but never used

const payload = github.context.payload
if (payload) {
console.log(JSON.stringify(payload))
return
}

const editIssueId = core.getInput('edit-issue-id')
if (editIssueId) {
console.log('Edit issue id:', editIssueId)
return
}

const pr = github.context.payload.pull_request
if (!pr) {
throw new Error('This action can only be run on pull requests')
}
const prDiff = await getPrDiff(octokit, pr.base.sha, pr.head.sha)
// const pr = github.context.payload.pull_request
// if (!pr) {
// throw new Error('This action can only be run on pull requests')
// }
// const prDiff = await getPrDiff(octokit, pr.base.sha, pr.head.sha)

const todos = findTodos(prDiff)
console.log('Todos:', JSON.stringify(todos))
// const todos = findTodos(prDiff)
// console.log('Todos:', JSON.stringify(todos))

const useOutput = core.getInput('use-output')
await commentPr(octokit, pr.number, todos)
// const useOutput = core.getInput('use-output')
// await commentPr(octokit, pr.number, todos)
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message)
Expand Down

0 comments on commit 5742078

Please sign in to comment.