-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into remove-option
- Loading branch information
Showing
10 changed files
with
93 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { Component, github } from 'projen'; | ||
import { JobPermission } from 'projen/lib/github/workflows-model'; | ||
import { TypeScriptProject } from 'projen/lib/typescript'; | ||
import { GitHubToken, stringifyList } from './util'; | ||
|
||
/** | ||
* See https://github.com/cdklabs/pr-triage-manager | ||
*/ | ||
interface PrLabelerOptions { | ||
/** | ||
* @default GitHubToken.GITHUB_TOKEN | ||
*/ | ||
githubToken?: GitHubToken; | ||
priorityLabels?: string[]; | ||
classificationLabels?: string[]; | ||
onPulls?: boolean; | ||
} | ||
|
||
function prLabelerJob(prLabelerOptions: PrLabelerOptions = {}) { | ||
return { | ||
name: 'PR Labeler', | ||
runsOn: ['aws-cdk_ubuntu-latest_4-core'], | ||
permissions: { issues: JobPermission.WRITE, pullRequests: JobPermission.WRITE }, | ||
steps: [ | ||
{ | ||
name: 'PR Labeler', | ||
uses: 'cdklabs/pr-triage-manager@main', | ||
with: { | ||
'github-token': `\${{ ${prLabelerOptions.githubToken ?? 'secrets.GITHUB_TOKEN'} }}`, | ||
'priority-labels': prLabelerOptions.priorityLabels ? stringifyList(prLabelerOptions.priorityLabels) : undefined, | ||
'classification-labels': prLabelerOptions.classificationLabels ? stringifyList(prLabelerOptions.classificationLabels) : undefined, | ||
'on-pulls': prLabelerOptions.onPulls, | ||
}, | ||
}, | ||
], | ||
}; | ||
} | ||
|
||
export class PrLabeler extends Component { | ||
public readonly workflow: github.GithubWorkflow; | ||
|
||
constructor(repo: TypeScriptProject) { | ||
super(repo); | ||
|
||
if (!repo.github) { | ||
throw new Error('Given repository does not have a GitHub component'); | ||
} | ||
|
||
this.workflow = repo.github.addWorkflow('pr-labeler'); | ||
this.workflow.on({ | ||
pullRequestTarget: { types: ['opened', 'edited', 'reopened'] }, | ||
}); | ||
|
||
this.workflow.addJob('copy-labels', prLabelerJob()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export enum GitHubToken { | ||
GITHUB_TOKEN = 'secrets.GITHUB_TOKEN', | ||
PROJEN_GITHUB_TOKEN = 'secrets.PROJEN_GITHUB_TOKEN', | ||
} | ||
|
||
export function stringifyList(list: string[]) { | ||
return `[${list.join('|')}]`; | ||
} |