File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed
Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -8520,13 +8520,20 @@ const run = async () => {
85208520 core.info('No users have special privileges to bypass protections');
85218521 }
85228522 } else {
8523- await octokit .rest.repos.deleteBranchProtection ({
8523+ const currProtection = await github .rest.repos.getBranchProtection ({
85248524 owner,
85258525 repo,
85268526 branch,
85278527 });
8528+ if (currProtection.status === 200) {
8529+ await octokit.rest.repos.deleteBranchProtection({
8530+ owner,
8531+ repo,
8532+ branch,
8533+ });
85288534
8529- core.info('Protection has been turned off.');
8535+ core.info('Protection has been turned off.');
8536+ }
85308537 }
85318538 } catch (e) {
85328539 console.error(e);
Original file line number Diff line number Diff line change 11{
22 "name" : " toggle-gh-protection" ,
3- "version" : " 1.0.6 " ,
3+ "version" : " 1.0.7 " ,
44 "main" : " dist/index.js" ,
55 "repository" : " git@github.com:ClearTax/toggle-gh-protection.git" ,
66 "author" : " Jagadish, K. <jagadish.kasi@cleartax.in>" ,
Original file line number Diff line number Diff line change @@ -50,13 +50,20 @@ const run = async () => {
5050 core . info ( 'No users have special privileges to bypass protections' ) ;
5151 }
5252 } else {
53- await octokit . rest . repos . deleteBranchProtection ( {
53+ const currProtection = await github . rest . repos . getBranchProtection ( {
5454 owner,
5555 repo,
5656 branch,
5757 } ) ;
58+ if ( currProtection . status === 200 ) {
59+ await octokit . rest . repos . deleteBranchProtection ( {
60+ owner,
61+ repo,
62+ branch,
63+ } ) ;
5864
59- core . info ( 'Protection has been turned off.' ) ;
65+ core . info ( 'Protection has been turned off.' ) ;
66+ }
6067 }
6168 } catch ( e ) {
6269 console . error ( e ) ;
You can’t perform that action at this time.
0 commit comments