Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions action.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ const waitForStatus = async ({
maxTimeout,
allowInactive,
checkIntervalInMilliseconds,
actorName = 'vercel[bot]',
}) => {
const octokit = new github.getOctokit(token);
const iterations = calculateIterations(
Expand All @@ -137,7 +138,9 @@ const waitForStatus = async ({
deployment_id,
});

const status = statuses.data.length > 0 && statuses.data[0];
const status =
statuses.data.length > 0 &&
statuses.data.find((status) => status.creator.login === actorName);

if (!status) {
throw new StatusError('No status was available');
Expand Down Expand Up @@ -218,11 +221,26 @@ const waitForDeploymentToStart = async ({
environment,
});

const deployment =
deployments.data.length > 0 &&
deployments.data.find((deployment) => {
return deployment.creator.login === actorName;
let deployment = null;
for (let n = 0; n < deployments.data.length; n++) {
const d = deployments.data[n];
if (d.creator.login === actorName) {
deployment = d;
break;
}
const statuses = await octokit.rest.repos.listDeploymentStatuses({
owner,
repo,
deployment_id: d.id,
});
if (
statuses.data.length > 0 &&
statuses.data.find((status) => status.creator.login === actorName)
) {
deployment = d;
break;
}
}

if (deployment) {
return deployment;
Expand Down Expand Up @@ -344,6 +362,7 @@ const run = async () => {
maxTimeout: MAX_TIMEOUT,
allowInactive: ALLOW_INACTIVE,
checkIntervalInMilliseconds: CHECK_INTERVAL_IN_MS,
actorName: 'vercel[bot]',
});

// Get target url
Expand Down
Loading