Skip to content

Commit

Permalink
Merge pull request #10 from mention-me/chore/add-additional-log-output
Browse files Browse the repository at this point in the history
Add additional logging during deployment
  • Loading branch information
ryanmab authored Oct 10, 2024
2 parents 7b5f400 + 4ad34f7 commit 6d287c1
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 7 deletions.
13 changes: 10 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export async function run(): Promise<void> {
const status = await waitForDeploymentToFinish(deployment);

if (status.isDeployed) {
core.info("Deployment successful!");
core.info(`Deployment of ${name} (${version}) in ${region} successful!`);
} else if (status.hasFailed) {
core.error("Deployment failed!");
core.error(`Deployment of ${name} (${version}) in ${region} failed!`);
}

core.setOutput("successful", status.isDeployed && !status.hasFailed);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export async function build(
}

try {
core.info(`Running build command at path: ${path}`);

await exec.exec(`${executable} connector build`, [], {
cwd: path,
silent: true,
Expand Down
17 changes: 17 additions & 0 deletions src/utils/deploy/startDeployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export async function startDeployment(
): Promise<Deployment> {
const apiKey = core.getInput("apiKey", { required: true });
const baseUrl = getApiBaseUrl(region);

core.info(
`Starting a deployment of ${connectorName} (${connectorVersion}) in ${region}`,
);

const encodedBuild = fs.readFileSync(`${buildPath}/connector.zip`, {
encoding: "base64",
});
Expand All @@ -42,17 +47,29 @@ export async function startDeployment(
core.debug(`Deployment response: ${JSON.stringify(response.data)}`);

if (response.status !== 200) {
core.error(
`Failed to start deployment. The error code returned was ${response.status}`,
);

throw new Error(
`Failed to start deployment: ${JSON.stringify(response.data)}`,
);
}

if (!response.data?.id) {
core.error(
`Failed to start deployment. The response did not contain a deployment ID`,
);

throw new Error(
`Unable to read deployment ID from response: ${response.data}`,
);
}

core.info(
`Deployment of ${connectorName} (${connectorVersion}) in ${region} started successfully. Deployment ID: ${response.data.id}`,
);

return {
region,
baseUrl,
Expand Down
8 changes: 7 additions & 1 deletion src/utils/deploy/waitForDeploymentToFinish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export async function waitForDeploymentToFinish(
attempts = 120,
waitTime = 2000,
): ReturnType<typeof getDeploymentStatus> {
core.info(
`Waiting for deployment of ${connectorName} (${connectorVersion}) in ${region} to finish...`,
);

for (let i = 1; i <= attempts; i++) {
const status = await getDeploymentStatus(
region,
Expand All @@ -24,10 +28,12 @@ export async function waitForDeploymentToFinish(
return status;
}

core.info(`Attempt ${i} of ${attempts}: the status is "${status.status}".`);

await new Promise((resolve) => setTimeout(resolve, waitTime));
}

core.debug(
core.info(
`Deployment timed out after ${attempts} attempts (with a ${waitTime / 1000} second wait time).`,
);

Expand Down

0 comments on commit 6d287c1

Please sign in to comment.