1
- import type { Installation , WebhookEvent } from '@octokit/webhooks-types'
1
+ import type { Installation , InstallationLite , WebhookEvent } from '@octokit/webhooks-types'
2
2
import type { H3Event } from 'h3'
3
3
import { App } from 'octokit'
4
4
@@ -15,7 +15,6 @@ export default defineEventHandler(async (event) => {
15
15
const promises : Promise < unknown > [ ] = [ ]
16
16
17
17
if ( 'action' in body && 'installation' in body && ! ( 'client_payload' in body ) ) {
18
- // new installation
19
18
if ( body . action === 'created' && 'repositories' in body ) {
20
19
for ( const repo of body . repositories || [ ] ) {
21
20
promises . push ( addRepo ( event , body . installation , repo ) )
@@ -38,6 +37,12 @@ export default defineEventHandler(async (event) => {
38
37
}
39
38
}
40
39
}
40
+ if ( body . action === 'publicized' && body . installation ) {
41
+ promises . push ( addRepo ( event , body . installation , body . repository ) )
42
+ }
43
+ if ( body . action === 'privatized' ) {
44
+ promises . push ( deleteRepo ( event , body . repository ) )
45
+ }
41
46
}
42
47
43
48
if ( 'issue' in body ) {
@@ -69,7 +74,10 @@ export type InstallationRepo = {
69
74
private : boolean
70
75
}
71
76
72
- async function addRepo ( event : H3Event , installation : Installation , repo : InstallationRepo ) {
77
+ async function addRepo ( event : H3Event , installation : Installation | InstallationLite , repo : InstallationRepo ) {
78
+ if ( repo . private ) {
79
+ return
80
+ }
73
81
const config = useRuntimeConfig ( event )
74
82
const app = new App ( {
75
83
appId : config . github . appId ,
0 commit comments