Skip to content

Commit

Permalink
Filter deployments with unique environments
Browse files Browse the repository at this point in the history
Signed-off-by: Kyle Harding <[email protected]>
  • Loading branch information
klutchell committed Nov 24, 2024
1 parent 83712d2 commit cf13a27
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,21 @@ export default (app: Probot) => {
continue;
}

for (const deployment of deployments) {
if (!deployment.current_user_can_approve) {
context.log.info(
'User %s cannot approve deployment %s',
appUser.login,
deployment.id,
);
continue;
}
// map deployments to their environment names
const environments = deployments
.filter((deployment) => deployment.current_user_can_approve)
.map((deployment) => deployment.environment.name);

for (const environment of environments) {
context.log.info(
'Reviewing deployment with run %s and environment %s',
run.id,
deployment.environment.name,
environment,
);
await GitHubClient.reviewWorkflowRun(
context,
run.id,
deployment.environment.name,
environment,
'approved',
`Approved by ${comment.user.login} via ${appUser.login}`,
);
Expand Down

0 comments on commit cf13a27

Please sign in to comment.