@@ -40,6 +40,8 @@ const project = new Cdk8sTeamJsiiProject({
40
40
} ,
41
41
} ,
42
42
golangBranch : '1.x' ,
43
+ backport : true ,
44
+ backportBranches : [ '1.x' ] ,
43
45
} ) ;
44
46
45
47
// _loadurl.js is written in javascript so we need to commit it and also copy it
@@ -63,88 +65,6 @@ docgenTask.exec('jsii-docgen -l typescript -o docs/typescript.md');
63
65
docgenTask . exec ( 'jsii-docgen -l python -o docs/python.md' ) ;
64
66
docgenTask . exec ( 'jsii-docgen -l java -o docs/java.md' ) ;
65
67
66
- // run backport in clean directories every time.
67
- const backportHome = '/tmp/.backport/' ;
68
- const backportDir = `${ backportHome } /repositories/cdk8s-team/cdk8s-core` ;
69
- const backportConfig = new JsonFile ( project , '.backportrc.json' , {
70
- // see https://github.com/sqren/backport/blob/main/docs/config-file-options.md
71
- obj : {
72
- repoOwner : 'cdk8s-team' ,
73
- repoName : 'cdk8s-core' ,
74
- signoff : true ,
75
- branchLabelMapping : {
76
- '^backport-to-(.+)$' : '$1' ,
77
- } ,
78
- prTitle : '{commitMessages}' ,
79
- fork : false ,
80
- publishStatusCommentOnFailure : true ,
81
- publishStatusCommentOnSuccess : true ,
82
- publishStatusCommentOnAbort : true ,
83
- targetPRLabels : [ project . autoApprove . label ] ,
84
- dir : backportDir ,
85
- } ,
86
- } ) ;
87
-
88
- // backport task to branches based on pr labels
89
- const backportTask = createBackportTask ( ) ;
90
-
91
- // backport tasks to the explicit release branches
92
- for ( const branch of project . release . branches ) {
93
- createBackportTask ( branch ) ;
94
- }
95
-
96
- const backportWorkflow = project . github . addWorkflow ( 'backport' ) ;
97
- backportWorkflow . on ( { pullRequestTarget : { types : [ 'closed' ] } } ) ;
98
- backportWorkflow . addJob ( 'backport' , {
99
- runsOn : [ 'ubuntu-latest' ] ,
100
- permissions : {
101
- contents : github . workflows . JobPermission . WRITE ,
102
- } ,
103
- steps : [
104
- // needed in order to run the projen task as well
105
- // as use the backport configuration in the repo.
106
- {
107
- name : 'checkout' ,
108
- uses : 'actions/checkout@v3' ,
109
- with : {
110
- // required because we need the full history
111
- // for proper backports.
112
- 'fetch-depth' : 0 ,
113
- } ,
114
- } ,
115
- {
116
- name : 'Set Git Identity' ,
117
- run :
'git config --global user.name "github-actions" && git config --global user.email "[email protected] "' ,
118
- } ,
119
- {
120
- name : 'backport' ,
121
- if : 'github.event.pull_request.merged == true' ,
122
- run : `npx projen ${ backportTask . name } ` ,
123
- env : {
124
- GITHUB_TOKEN : '${{ secrets.PROJEN_GITHUB_TOKEN }}' ,
125
- BACKPORT_PR_NUMBER : '${{ github.event.pull_request.number }}' ,
126
- } ,
127
- } ,
128
- ] ,
129
- } ) ;
130
-
131
- function createBackportTask ( branch ) {
132
- const name = branch ? `backport:${ branch } ` : 'backport' ;
133
- const task = project . addTask ( name , { requiredEnv : [ 'BACKPORT_PR_NUMBER' , 'GITHUB_TOKEN' ] } ) ;
134
- task . exec ( `rm -rf ${ backportHome } ` ) ;
135
- task . exec ( `mkdir -p ${ backportHome } ` ) ;
136
- task . exec ( `cp ${ backportConfig . path } ${ backportHome } ` ) ;
137
-
138
- const command = [ 'npx' , 'backport' , '--accesstoken' , '${GITHUB_TOKEN}' , '--pr' , '${BACKPORT_PR_NUMBER}' ] ;
139
- if ( branch ) {
140
- command . push ( ...[ '--branch' , branch ] ) ;
141
- } else {
142
- command . push ( '--non-interactive' ) ;
143
- }
144
- task . exec ( command . join ( ' ' ) , { cwd : backportHome } ) ;
145
- return task ;
146
- }
147
-
148
68
// https://github.com/DefinitelyTyped/DefinitelyTyped/pull/64924
149
69
project . package . addPackageResolutions ( '@types/[email protected] ' ) ;
150
70
0 commit comments