Skip to content

Commit ad07d5f

Browse files
committed
v1.0.7
1 parent 776841e commit ad07d5f

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

dist/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff 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);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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>",

src/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff 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);

0 commit comments

Comments
 (0)