Skip to content

Commit

Permalink
Again
Browse files Browse the repository at this point in the history
  • Loading branch information
rehlma committed Apr 9, 2024
1 parent 8fd4f6d commit 03b8556
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 19 deletions.
26 changes: 21 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29142,17 +29142,33 @@ function commentPr(octokit, comment, headSha, todoCount, doneCount) {
});
}
console.log('Current head sha is:', headSha);
yield octokit.rest.repos.createCommitStatus({
yield octokit.rest.repos
.addStatusCheckContexts({
owner,
repo,
branch: headSha,
contexts: ['todo-check']
})
.then(() => {
console.log('Added status check context');
})
.catch(error => {
console.log('Error adding status check context:', error);
});
yield octokit.rest.repos
.createCommitStatus({
owner,
repo,
sha: headSha,
state: 'success',
description: `${doneCount}/${todoCount} TODOs checked`,
context: 'todo-check'
}).then(() => {
console.log('Added status check context');
}).catch((error) => {
console.log('Error adding status check context:', error);
})
.then(() => {
console.log('Commit status created');
})
.catch(error => {
console.log('Error creating commit status', error);
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

49 changes: 36 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ export async function run(): Promise<void> {
} else {
const comment = generateComment(newTodos, removedTodos)

await commentPr(octokit, comment, headRef, newTodos.length + removedTodos.length, removedTodos.length)
await commentPr(
octokit,
comment,
headRef,
newTodos.length + removedTodos.length,
removedTodos.length
)
core.setOutput('comment', comment)
}
} catch (error) {
Expand Down Expand Up @@ -147,16 +153,33 @@ async function commentPr(

console.log('Current head sha is:', headSha)

await octokit.rest.repos.createCommitStatus({
owner,
repo,
sha: headSha,
state: 'success',
description: `${doneCount}/${todoCount} TODOs checked`,
context: 'todo-check'
}).then(() => {
console.log('Added status check context')
}).catch((error) => {
console.log('Error adding status check context:', error)
})
await octokit.rest.repos
.addStatusCheckContexts({
owner,
repo,
branch: headSha,
contexts: ['todo-check']
})
.then(() => {

Check failure on line 163 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Prefer async/await to Promise.then()

Check failure on line 163 in src/main.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Prefer async/await to Promise.then()
console.log('Added status check context')
})
.catch(error => {

Check failure on line 166 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Prefer async/await to Promise.catch()

Check failure on line 166 in src/main.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Prefer async/await to Promise.catch()
console.log('Error adding status check context:', error)
})

await octokit.rest.repos
.createCommitStatus({
owner,
repo,
sha: headSha,
state: 'success',
description: `${doneCount}/${todoCount} TODOs checked`,
context: 'todo-check'
})
.then(() => {

Check failure on line 179 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Prefer async/await to Promise.then()

Check failure on line 179 in src/main.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Prefer async/await to Promise.then()
console.log('Commit status created')
})
.catch(error => {

Check failure on line 182 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Prefer async/await to Promise.catch()

Check failure on line 182 in src/main.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Prefer async/await to Promise.catch()
console.log('Error creating commit status', error)
})
}

0 comments on commit 03b8556

Please sign in to comment.