Skip to content

Commit 0039b8c

Browse files
fix: let projects fix missing protections
1 parent 7c48d4b commit 0039b8c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/server/api/project/config.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,29 @@ export async function updateGitHubActionsEnvironment(
9999
custom_branch_policies: true,
100100
},
101101
});
102+
}
103+
104+
for (let attempt = 0; attempt < 4; attempt++) {
105+
if (attempt > 0) {
106+
// Wait a bit before retrying
107+
await new Promise((resolve) => setTimeout(resolve, 2000));
108+
}
109+
110+
if (attempt === 3) {
111+
return GitHubActionsEnvironmentResult.UNKNOWN_ERROR;
112+
}
113+
114+
const existingPolicy = (
115+
await github.repos.listDeploymentBranchPolicies({
116+
owner: project.repoOwner,
117+
repo: project.repoName,
118+
environment_name: CFA_RELEASE_GITHUB_ENVIRONMENT_NAME,
119+
})
120+
).data.branch_policies.find((p) => p.name === project.defaultBranch);
121+
122+
if (existingPolicy) {
123+
break;
124+
}
102125

103126
await github.repos.createDeploymentBranchPolicy({
104127
owner: project.repoOwner,

0 commit comments

Comments
 (0)