@@ -2300,7 +2300,10 @@ function run() {
23002300 const calls = [ ] ;
23012301 for ( const repo of repos ) {
23022302 for ( const k of Object . keys ( secrets ) ) {
2303- calls . push ( limit ( ( ) => github_1 . setSecretForRepo ( octokit , k , secrets [ k ] , repo , config . DRY_RUN ) ) ) ;
2303+ const action = config . RUN_DELETE
2304+ ? github_1 . deleteSecretForRepo
2305+ : github_1 . setSecretForRepo ;
2306+ calls . push ( limit ( ( ) => action ( octokit , k , secrets [ k ] , repo , config . DRY_RUN ) ) ) ;
23042307 }
23052308 }
23062309 yield Promise . all ( calls ) ;
@@ -5728,7 +5731,8 @@ function getConfig() {
57285731 REPOSITORIES_LIST_REGEX : [ "1" , "true" ] . includes ( core
57295732 . getInput ( "REPOSITORIES_LIST_REGEX" , { required : false } )
57305733 . toLowerCase ( ) ) ,
5731- DRY_RUN : [ "1" , "true" ] . includes ( core . getInput ( "DRY_RUN" , { required : false } ) . toLowerCase ( ) )
5734+ DRY_RUN : [ "1" , "true" ] . includes ( core . getInput ( "DRY_RUN" , { required : false } ) . toLowerCase ( ) ) ,
5735+ RUN_DELETE : [ "1" , "true" ] . includes ( core . getInput ( "DELETE" , { required : false } ) . toLowerCase ( ) )
57325736 } ;
57335737 if ( config . DRY_RUN ) {
57345738 core . info ( "[DRY_RUN='true'] No changes will be written to secrets" ) ;
@@ -7744,6 +7748,22 @@ function setSecretForRepo(octokit, name, secret, repo, dry_run) {
77447748 } ) ;
77457749}
77467750exports . setSecretForRepo = setSecretForRepo ;
7751+ function deleteSecretForRepo ( octokit , name , secret , repo , dry_run ) {
7752+ return __awaiter ( this , void 0 , void 0 , function * ( ) {
7753+ core . info ( `Remove ${ name } from ${ repo . full_name } ` ) ;
7754+ try {
7755+ if ( ! dry_run ) {
7756+ const action = "DELETE" ;
7757+ const request = `/repos/${ repo . full_name } /actions/secrets/${ name } ` ;
7758+ return octokit . request ( `${ action } ${ request } ` ) ;
7759+ }
7760+ }
7761+ catch ( HttpError ) {
7762+ //If secret is not found in target repo, silently continue
7763+ }
7764+ } ) ;
7765+ }
7766+ exports . deleteSecretForRepo = deleteSecretForRepo ;
77477767
77487768
77497769/***/ } ) ,
0 commit comments