Skip to content

Commit e209094

Browse files
committed
Handle failures in createGitHubDeployment and createGitHubJobSummary
1 parent 181b9fb commit e209094

File tree

3 files changed

+50
-22
lines changed

3 files changed

+50
-22
lines changed

.changeset/lemon-bags-happen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler-action": patch
3+
---
4+
5+
Handle failures in createGitHubDeployment and createGitHubJobSummary

src/service/github.ts

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { summary } from "@actions/core";
22
import { context, getOctokit } from "@actions/github";
33
import { env } from "process";
4-
import { info } from "../utils";
4+
import { info, warn } from "../utils";
55
import { OutputEntryPagesDeployment } from "../wranglerArtifactManager";
66
import { WranglerActionConfig } from "../wranglerAction";
77

@@ -95,25 +95,34 @@ export async function createGitHubDeploymentAndJobSummary(
9595
pagesArtifactFields.deployment_trigger
9696
) {
9797
const octokit = getOctokit(config.GITHUB_TOKEN);
98-
await Promise.all([
99-
createGitHubDeployment({
100-
config,
101-
octokit,
102-
deploymentUrl: pagesArtifactFields.url,
103-
productionBranch: pagesArtifactFields.production_branch,
104-
environment: pagesArtifactFields.environment,
105-
deploymentId: pagesArtifactFields.deployment_id,
106-
projectName: pagesArtifactFields.pages_project,
107-
}),
108-
createJobSummary({
109-
commitHash:
110-
pagesArtifactFields.deployment_trigger.metadata.commit_hash.substring(
111-
0,
112-
8,
113-
),
114-
deploymentUrl: pagesArtifactFields.url,
115-
aliasUrl: pagesArtifactFields.alias,
116-
}),
117-
]);
98+
const [createGitHubDeploymentRes, createJobSummaryRes] =
99+
await Promise.allSettled([
100+
createGitHubDeployment({
101+
config,
102+
octokit,
103+
deploymentUrl: pagesArtifactFields.url,
104+
productionBranch: pagesArtifactFields.production_branch,
105+
environment: pagesArtifactFields.environment,
106+
deploymentId: pagesArtifactFields.deployment_id,
107+
projectName: pagesArtifactFields.pages_project,
108+
}),
109+
createJobSummary({
110+
commitHash:
111+
pagesArtifactFields.deployment_trigger.metadata.commit_hash.substring(
112+
0,
113+
8,
114+
),
115+
deploymentUrl: pagesArtifactFields.url,
116+
aliasUrl: pagesArtifactFields.alias,
117+
}),
118+
]);
119+
120+
if (createGitHubDeploymentRes.status === "rejected") {
121+
warn(config, "Creating Github Deployment failed");
122+
}
123+
124+
if (createJobSummaryRes.status === "rejected") {
125+
warn(config, "Creating Github Job summary failed");
126+
}
118127
}
119128
}

src/utils.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { existsSync } from "node:fs";
22
import * as path from "node:path";
33
import semverGt from "semver/functions/gt";
4-
import { info as originalInfo, error as originalError } from "@actions/core";
4+
import {
5+
info as originalInfo,
6+
error as originalError,
7+
warning as originalWarn,
8+
} from "@actions/core";
59
import { WranglerActionConfig } from "./wranglerAction";
610

711
/**
@@ -32,6 +36,16 @@ export function info(
3236
}
3337
}
3438

39+
export function warn(
40+
config: WranglerActionConfig,
41+
message: string,
42+
bypass?: boolean,
43+
): void {
44+
if (!config.QUIET_MODE || bypass) {
45+
originalWarn(message);
46+
}
47+
}
48+
3549
export function error(
3650
config: WranglerActionConfig,
3751
message: string,

0 commit comments

Comments
 (0)