Skip to content

Commit

Permalink
No longer return on a single deployment that is not queued
Browse files Browse the repository at this point in the history
  • Loading branch information
Qrious committed Oct 14, 2020
1 parent cc49ce7 commit 9041d9d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const github = require('@actions/github');
const octokit = github.getOctokit(authToken);

const output = [];
const seenEnvironments = [];

for await (const {data: deployments} of octokit.paginate.iterator(
octokit.repos.listDeployments,
Expand All @@ -21,6 +22,9 @@ const github = require('@actions/github');
)) {
for (const deployment of deployments) {
core.info(`Deployment: ${deployment.environment} (#${deployment.id})`);
if (seenEnvironments[deployment.environment]) {
continue;
}
const {data: statuses } = await octokit.repos.listDeploymentStatuses({
owner,
repo,
Expand All @@ -33,6 +37,7 @@ const github = require('@actions/github');
core.info(`Status: ${deployment.environment} (#${deployment.id}) ${statuses[0].state}`);
// The list of statuses is sorted on last to first.
// If it is not queued, this deployment has already been handled.
seenEnvironments[deployment.environment] = true;
if (statuses[0].state !== "queued") {
continue;
}
Expand Down

0 comments on commit 9041d9d

Please sign in to comment.