-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathclass.ts
More file actions
609 lines (549 loc) · 22.3 KB
/
class.ts
File metadata and controls
609 lines (549 loc) · 22.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
import type { Project, ProjectMember, UniqueRepo } from '@cpn-console/hooks'
import type { VaultProjectApi } from '@cpn-console/vault-plugin/types/vault-project-api.js'
import type { AccessTokenScopes, AllRepositoryTreesOptions, CommitAction, CondensedProjectSchema, Gitlab, GroupSchema, MemberSchema, ProjectSchema, ProjectVariableSchema, RepositoryFileExpandedSchema, VariableSchema } from '@gitbeaker/core'
import type { GitbeakerRequestError } from '@gitbeaker/requester-utils'
import { createHash } from 'node:crypto'
import { PluginApi } from '@cpn-console/hooks'
import { objectEntries } from '@cpn-console/shared'
import { AccessLevel } from '@gitbeaker/core'
import config from './config.js'
import { find, getAll, getApi, getGroupRootId, infraAppsRepoName, internalMirrorRepoName, offsetPaginate } from './utils.js'
type setVariableResult = 'created' | 'updated' | 'already up-to-date'
type AccessLevelAllowed = AccessLevel.NO_ACCESS | AccessLevel.MINIMAL_ACCESS | AccessLevel.GUEST | AccessLevel.REPORTER | AccessLevel.DEVELOPER | AccessLevel.MAINTAINER | AccessLevel.OWNER
const infraGroupName = 'Infra'
const infraGroupPath = 'infra'
export const pluginManagedTopic = 'plugin-managed'
interface GitlabMirrorSecret {
MIRROR_USER: string
MIRROR_TOKEN: string
}
interface RepoSelect {
mirror?: CondensedProjectSchema
target?: CondensedProjectSchema
}
type PendingCommits = Record<number, {
branches: Record<string, { messages: string[], actions: CommitAction[] }>
}>
interface CreateEmptyRepositoryArgs {
repoName: string
description?: string
}
export class GitlabApi extends PluginApi {
protected api: Gitlab<false>
private pendingCommits: PendingCommits = {}
constructor() {
super()
this.api = getApi()
}
public async createEmptyRepository({ createFirstCommit, groupId, repoName, description, ciConfigPath }: CreateEmptyRepositoryArgs & {
createFirstCommit: boolean
groupId: number
ciConfigPath?: string
}) {
console.log(`[GITLAB] createEmptyRepository ${repoName} ${groupId}`)
const project = await this.api.Projects.create({
name: repoName,
path: repoName,
ciConfigPath,
namespaceId: groupId,
description,
})
// Dépôt tout juste créé, zéro branche => pas d'erreur (filesTree undefined)
if (createFirstCommit) {
await this.api.Commits.create(project.id, 'main', 'ci: 🌱 First commit', [])
}
return project
}
public async commitCreateOrUpdate(
repoId: number,
fileContent: string,
filePath: string,
branch: string = 'main',
comment: string = 'ci: :robot_face: Update file content',
): Promise<boolean> {
console.log(`[GITLAB] commitCreateOrUpdate ${repoId} ${filePath} ${branch}`)
let action: CommitAction['action'] = 'create'
const existingBranch = await find(offsetPaginate(opts => this.api.Branches.all(repoId, opts)), b => b.name === branch)
if (existingBranch) {
let actualFile: RepositoryFileExpandedSchema | undefined
try {
actualFile = await this.api.RepositoryFiles.show(repoId, filePath, branch)
} catch {}
if (actualFile) {
const newContentDigest = createHash('sha256').update(fileContent).digest('hex')
if (actualFile.content_sha256 === newContentDigest) {
// Already up-to-date
return false
}
// Update needed
action = 'update'
}
}
const commitAction: CommitAction = {
action,
filePath,
content: fileContent,
}
this.addActions(repoId, branch, comment, [commitAction])
return true
}
/**
* Fonction pour supprimer une liste de fichiers d'un repo
* @param repoId
* @param files
* @param branch
* @param comment
*/
public async commitDelete(
repoId: number,
files: string[],
branch: string = 'main',
comment: string = 'ci: :robot_face: Delete files',
): Promise<boolean> {
console.log(`[GITLAB] commitDelete ${repoId} ${branch}`)
if (files.length) {
const commitActions: CommitAction[] = files.map((filePath) => {
return {
action: 'delete',
filePath,
}
})
this.addActions(repoId, branch, comment, commitActions)
return true
}
return false
}
private addActions(repoId: number, branch: string, comment: string, commitActions: CommitAction[]) {
if (!this.pendingCommits[repoId]) {
this.pendingCommits[repoId] = { branches: {} }
}
if (this.pendingCommits[repoId].branches[branch]) {
this.pendingCommits[repoId].branches[branch].actions.push(...commitActions)
this.pendingCommits[repoId].branches[branch].messages.push(comment)
} else {
this.pendingCommits[repoId].branches[branch] = {
actions: commitActions,
messages: [comment],
}
}
}
public async commitFiles() {
console.log(`[GITLAB] commitFiles`)
let filesUpdated: number = 0
for (const [id, repo] of objectEntries(this.pendingCommits)) {
for (const [branch, details] of objectEntries(repo.branches)) {
const filesNumber = details.actions.length
if (filesNumber) {
filesUpdated += filesNumber
const message = [`ci: :robot_face: Update ${filesNumber} file${filesNumber > 1 ? 's' : ''}`, ...details.messages.filter(m => m)].join('\n')
await this.api.Commits.create(id, branch, message, details.actions)
}
}
}
return filesUpdated
}
public async listFiles(repoId: number, options: AllRepositoryTreesOptions = {}) {
console.log(`[GITLAB] listFiles ${repoId}`)
options.path = options?.path ?? '/'
options.ref = options?.ref ?? 'main'
options.recursive = options?.recursive ?? false
try {
const files = await this.api.Repositories.allRepositoryTrees(repoId, options)
// if (depth >= 0) {
// for (const file of files) {
// if (file.type !== 'tree') {
// return []
// }
// const childrenFiles = await this.listFiles(repoId, { depth: depth - 1, ...options, path: file.path })
// console.trace({ file, childrenFiles })
// files.push(...childrenFiles)
// }
// }
return files
} catch (error) {
const { cause } = error as GitbeakerRequestError
if (cause?.description.includes('Not Found')) {
// Empty repository, with zero commit ==> Zero files
return []
} else {
throw error
}
}
}
public async deleteRepository(repoId: number, fullPath: string) {
console.log(`[GITLAB] deleteRepository ${repoId} ${fullPath}`)
await this.api.Projects.remove(repoId) // Marks for deletion
return this.api.Projects.remove(repoId, { permanentlyRemove: true, fullPath: `${fullPath}-deletion_scheduled-${repoId}` }) // Effective deletion
}
}
export class GitlabZoneApi extends GitlabApi {
private infraProjectsByZoneSlug: Map<string, ProjectSchema>
constructor() {
super()
this.infraProjectsByZoneSlug = new Map()
}
// Group Infra
public async getOrCreateInfraGroup(): Promise<GroupSchema> {
console.log(`[GITLAB] getOrCreateInfraGroup`)
const rootId = await getGroupRootId()
// Get or create projects_root_dir/infra group
const existingParentGroup = await find(offsetPaginate(opts => this.api.Groups.all({
search: infraGroupName,
orderBy: 'id',
...opts,
})), group => group.parent_id === rootId && group.name === infraGroupName)
return existingParentGroup || await this.api.Groups.create(infraGroupName, infraGroupPath, {
parentId: rootId,
projectCreationLevel: 'maintainer',
subgroupCreationLevel: 'owner',
defaultBranchProtection: 0,
description: 'Group that hosts infrastructure-as-code repositories for all zones (ArgoCD pull targets).',
})
}
public async getOrCreateInfraProject(zone: string): Promise<ProjectSchema> {
console.log(`[GITLAB] getOrCreateInfraProject ${zone}`)
if (this.infraProjectsByZoneSlug.has(zone)) {
return this.infraProjectsByZoneSlug.get(zone)!
}
const infraGroup = await this.getOrCreateInfraGroup()
// Get or create projects_root_dir/infra/zone
const project = await find(offsetPaginate(opts => this.api.Groups.allProjects(infraGroup.id, {
search: zone,
simple: true,
...opts,
})), repo => repo.name === zone) ?? await this.createEmptyRepository({
repoName: zone,
groupId: infraGroup.id,
description: 'Repository hosting deployment files for this zone.',
createFirstCommit: true,
})
this.infraProjectsByZoneSlug.set(zone, project)
return project
}
}
export class GitlabProjectApi extends GitlabApi {
private project: Project | UniqueRepo | ProjectMember['project']
private gitlabGroup: GroupSchema | undefined
private specialRepositories: string[] = [infraAppsRepoName, internalMirrorRepoName]
private zoneApi: GitlabZoneApi
constructor(project: Project | UniqueRepo | ProjectMember['project']) {
super()
this.project = project
this.api = getApi()
this.zoneApi = new GitlabZoneApi()
}
// Group Project
private async createProjectGroup(): Promise<GroupSchema> {
console.log(`[GITLAB] createProjectGroup`)
const parentId = await getGroupRootId()
const existingGroup = await find(offsetPaginate(opts => this.api.Groups.all({
search: this.project.slug,
orderBy: 'id',
...opts,
})), group => group.parent_id === parentId && group.name === this.project.slug)
if (existingGroup) return existingGroup
return this.api.Groups.create(this.project.slug, this.project.slug, {
parentId,
projectCreationLevel: 'maintainer',
subgroupCreationLevel: 'owner',
defaultBranchProtection: 0,
})
}
public async getProjectGroup(): Promise<GroupSchema | undefined> {
console.log(`[GITLAB] getProjectGroup`)
if (!this.gitlabGroup) {
console.log(`[GITLAB] No gitlab group defined in internal state`)
const parentId = await getGroupRootId()
this.gitlabGroup = await find(offsetPaginate(opts => this.api.Groups.allSubgroups(parentId, opts)), group => group.name === this.project.slug)
}
console.log(`[GITLAB] FOUND gitlabGroup`)
return this.gitlabGroup
}
public async getOrCreateProjectGroup(): Promise<GroupSchema> {
console.log(`[GITLAB] getOrCreateProjectGroup`)
const group = await this.getProjectGroup()
if (group) return group
return this.createProjectGroup()
}
public async getPublicGroupUrl() {
console.log(`[GITLAB] getPublicGroupUrl`)
return `${config().publicUrl}/${config().projectsRootDir}/${this.project.slug}`
}
public async getInternalGroupUrl() {
console.log(`[GITLAB] getInternalGroupUrl`)
return `${config().internalUrl}/${config().projectsRootDir}/${this.project.slug}`
}
// Tokens
public async getProjectMirrorCreds(vaultApi: VaultProjectApi): Promise<GitlabMirrorSecret> {
console.log(`[GITLAB] getProjectMirrorCreds`)
const tokenName = `${this.project.slug}-bot`
const currentToken = await this.getProjectToken(tokenName)
const creds: GitlabMirrorSecret = {
MIRROR_USER: '',
MIRROR_TOKEN: '',
}
if (currentToken) {
const vaultSecret = await vaultApi.read('tech/GITLAB_MIRROR', { throwIfNoEntry: false }) as { data: GitlabMirrorSecret }
if (vaultSecret) {
try {
const group = await this.getProjectGroup()
if (!group) throw new Error('Group not created yet')
const res = await fetch(`${config().internalUrl}/api/v4/groups/${group.id}`, {
headers: { 'PRIVATE-TOKEN': vaultSecret.data.MIRROR_TOKEN },
})
if (res.ok) {
return vaultSecret.data // valid token hence early exit
}
throw new Error('Invalid token')
} catch (error) {
console.warn('Warning:', error)
await this.revokeProjectToken(currentToken.id)
}
}
}
const newToken = await this.createProjectToken(tokenName, ['write_repository', 'read_repository', 'read_api'])
creds.MIRROR_TOKEN = newToken.token
creds.MIRROR_USER = newToken.name
await vaultApi.write(creds, 'tech/GITLAB_MIRROR')
return creds
}
public async getProjectId(projectName: string) {
console.log(`[GITLAB] getProjectId ${projectName}`)
const projectGroup = await this.getProjectGroup()
if (!projectGroup) throw new Error(`Gitlab inaccessible, impossible de trouver le groupe ${this.project.slug}`)
const project = await find(offsetPaginate(opts => this.api.Groups.allProjects(projectGroup.id, {
search: projectName,
simple: true,
...opts,
})), repo => repo.name === projectName)
return project?.id
}
public async getProjectById(projectId: number) {
console.log(`[GITLAB] getProjectById ${projectId}`)
return this.api.Projects.show(projectId)
}
public async getOrCreateInfraProject(zone: string) {
console.log(`[GITLAB] getOrCreateInfraGroup ${zone}`)
return await this.zoneApi.getOrCreateInfraProject(zone)
}
public async getProjectToken(tokenName: string) {
console.log(`[GITLAB] getProjectToken ${tokenName}`)
const group = await this.getProjectGroup()
if (!group) throw new Error('Unable to retrieve gitlab project group')
return find(offsetPaginate(opts => this.api.GroupAccessTokens.all(group.id, opts)), token => token.name === tokenName)
}
public async createProjectToken(tokenName: string, scopes: AccessTokenScopes[]) {
console.log(`[GITLAB] createProjectToken ${tokenName}`)
const group = await this.getProjectGroup()
if (!group) throw new Error('Unable to retrieve gitlab project group')
const expiryDate = new Date()
expiryDate.setFullYear(expiryDate.getFullYear() + 1)
return this.api.GroupAccessTokens.create(group.id, tokenName, scopes, expiryDate.toLocaleDateString('en-CA'))
}
public async revokeProjectToken(tokenId: number) {
console.log(`[GITLAB] revokeProjectToken ${tokenId}`)
const group = await this.getProjectGroup()
if (!group) throw new Error('Unable to retrieve gitlab project group')
return this.api.GroupAccessTokens.revoke(group.id, tokenId)
}
// Triggers
public async getMirrorProjectTriggerToken(vaultApi: VaultProjectApi) {
console.log(`[GITLAB] getMirrorProjectTriggerToken`)
const tokenDescription = 'mirroring-from-external-repo'
const gitlabRepositories = await this.listRepositories()
const mirrorRepo = gitlabRepositories.find(repo => repo.name === internalMirrorRepoName)
if (!mirrorRepo) throw new Error('Don\'t know how mirror repo could not exist')
const currentTriggerToken = await find(offsetPaginate(opts => this.api.PipelineTriggerTokens.all(mirrorRepo.id, opts)), token => token.description === tokenDescription)
const tokenVaultSecret = await vaultApi.read('GITLAB', { throwIfNoEntry: false })
if (currentTriggerToken && !tokenVaultSecret?.data?.GIT_MIRROR_TOKEN) {
await this.api.PipelineTriggerTokens.remove(mirrorRepo.id, currentTriggerToken.id)
}
const triggerToken = await this.api.PipelineTriggerTokens.create(mirrorRepo.id, tokenDescription)
return { token: triggerToken.token, repoId: mirrorRepo.id }
}
// Repositories
public async getPublicRepoUrl(repoName: string) {
console.log(`[GITLAB] getPublicRepoUrl ${repoName}`)
return `${await this.getPublicGroupUrl()}/${repoName}.git`
}
public async getInternalRepoUrl(repoName: string) {
console.log(`[GITLAB] getInternalRepoUrl ${repoName}`)
return `${await this.getInternalGroupUrl()}/${repoName}.git`
}
public async listRepositories() {
console.log(`[GITLAB] listRepositories`)
const group = await this.getOrCreateProjectGroup()
const projects = await getAll(offsetPaginate(opts => this.api.Groups.allProjects(group.id, { simple: false, ...opts }))) // to refactor with https://github.com/jdalrymple/gitbeaker/pull/3624
return Promise.all(projects.map(async (project) => {
if (this.specialRepositories.includes(project.name) && (!project.topics || !project.topics.includes(pluginManagedTopic))) {
return this.api.Projects.edit(project.id, { topics: project.topics ? [...project.topics, pluginManagedTopic] : [pluginManagedTopic] })
}
return project
}))
}
public async createEmptyProjectRepository({ repoName, description, clone }: CreateEmptyRepositoryArgs & { clone?: boolean }) {
console.log(`[GITLAB] createEmptyProjectRepository ${repoName}`)
const namespaceId = (await this.getOrCreateProjectGroup()).id
return this.createEmptyRepository({
repoName,
groupId: namespaceId,
description,
ciConfigPath: clone ? '.gitlab-ci-dso.yml' : undefined,
createFirstCommit: !clone,
})
}
// Special Repositories
public async getSpecialRepositories(): Promise<string[]> {
console.log(`[GITLAB] getSpecialRepositories`)
return this.specialRepositories
}
public async addSpecialRepositories(name: string) {
console.log(`[GITLAB] addSpecialRepositories ${name}`)
if (!this.specialRepositories.includes(name)) {
this.specialRepositories.push(name)
}
}
// Group members
public async getGroupMembers() {
console.log(`[GITLAB] getGroupMembers`)
const group = await this.getOrCreateProjectGroup()
return getAll(offsetPaginate(opts => this.api.GroupMembers.all(group.id, opts)))
}
public async addGroupMember(userId: number, accessLevel: AccessLevelAllowed = AccessLevel.DEVELOPER): Promise<MemberSchema> {
console.log(`[GITLAB] addGroupMember ${userId} ${accessLevel}`)
const group = await this.getOrCreateProjectGroup()
return this.api.GroupMembers.add(group.id, userId, accessLevel as any)
}
public async editGroupMember(userId: number, accessLevel: AccessLevelAllowed = AccessLevel.DEVELOPER): Promise<MemberSchema> {
console.log(`[GITLAB] editGroupMember ${userId} ${accessLevel}`)
const group = await this.getOrCreateProjectGroup()
return this.api.GroupMembers.edit(group.id, userId, accessLevel)
}
public async removeGroupMember(userId: number) {
console.log(`[GITLAB] removeGroupMember ${userId}`)
const group = await this.getOrCreateProjectGroup()
return this.api.GroupMembers.remove(group.id, userId)
}
// CI Variables
public async getGitlabGroupVariables(): Promise<VariableSchema[]> {
console.log(`[GITLAB] getGitlabGroupVariables`)
const group = await this.getOrCreateProjectGroup()
return await getAll(offsetPaginate(opts => this.api.GroupVariables.all(group.id, opts)))
}
public async setGitlabGroupVariable(listVars: VariableSchema[], toSetVariable: VariableSchema): Promise<setVariableResult> {
console.log(`[GITLAB] setGitlabGroupVariable`)
const group = await this.getOrCreateProjectGroup()
const currentVariable = listVars.find(v => v.key === toSetVariable.key)
if (currentVariable) {
if (
currentVariable.masked !== toSetVariable.masked
|| currentVariable.value !== toSetVariable.value
|| currentVariable.protected !== toSetVariable.protected
|| currentVariable.variable_type !== toSetVariable.variable_type
) {
await this.api.GroupVariables.edit(
group.id,
toSetVariable.key,
toSetVariable.value,
{
variableType: toSetVariable.variable_type,
masked: toSetVariable.masked,
protected: toSetVariable.protected,
filter: { environment_scope: '*' },
},
)
return 'updated'
}
return 'already up-to-date'
}
await this.api.GroupVariables.create(
group.id,
toSetVariable.key,
toSetVariable.value,
{
variableType: toSetVariable.variable_type,
masked: toSetVariable.masked,
protected: toSetVariable.protected,
},
)
return 'created'
}
public async getGitlabRepoVariables(repoId: number): Promise<VariableSchema[]> {
console.log(`[GITLAB] getGitlabRepoVariables ${repoId}`)
return await getAll(offsetPaginate(opts => this.api.ProjectVariables.all(repoId, opts)))
}
public async setGitlabRepoVariable(repoId: number, listVars: VariableSchema[], toSetVariable: ProjectVariableSchema): Promise<setVariableResult | 'repository not found'> {
console.log(`[GITLAB] setGitlabRepoVariables ${repoId}`)
const currentVariable = listVars.find(v => v.key === toSetVariable.key)
if (currentVariable) {
if (
currentVariable.masked !== toSetVariable.masked
|| currentVariable.value !== toSetVariable.value
|| currentVariable.protected !== toSetVariable.protected
|| currentVariable.variable_type !== toSetVariable.variable_type
) {
await this.api.ProjectVariables.edit(
repoId,
toSetVariable.key,
toSetVariable.value,
{
variableType: toSetVariable.variable_type,
masked: toSetVariable.masked,
protected: toSetVariable.protected,
filter: {
environment_scope: toSetVariable.environment_scope,
},
},
)
return 'updated'
}
return 'already up-to-date'
}
await this.api.ProjectVariables.create(
repoId,
toSetVariable.key,
toSetVariable.value,
{
variableType: toSetVariable.variable_type,
masked: toSetVariable.masked,
protected: toSetVariable.protected,
},
)
return 'created'
}
// Mirror
public async triggerMirror(targetRepo: string, syncAllBranches: boolean, branchName?: string) {
console.log(`[GITLAB] triggerMirror ${targetRepo} ${syncAllBranches} ${branchName}`)
if ((await this.getSpecialRepositories()).includes(targetRepo)) {
throw new Error('User requested for invalid mirroring')
}
const repos = await this.listRepositories()
const { mirror, target }: RepoSelect = repos.reduce((acc, repository) => {
if (repository.name === 'mirror') {
acc.mirror = repository
}
if (repository.name === targetRepo) {
acc.target = repository
}
return acc
}, {} as RepoSelect)
if (!mirror) throw new Error('Unable to find mirror repository')
if (!target) throw new Error('Unable to find target repository')
return this.api.Pipelines.create(mirror.id, 'main', {
variables: [
{
key: 'SYNC_ALL',
value: syncAllBranches.toString(),
},
{
key: 'GIT_BRANCH_DEPLOY',
value: branchName ?? '',
},
{
key: 'PROJECT_NAME',
value: targetRepo,
},
],
})
}
}