mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2025-04-24 17:29:08 +02:00
Merge pull request #350 from cloudflare/maximo/handle-failures-in-create-github-deployment-and-job-summary
Handle failures in createGitHubDeployment and createGitHubJobSummary
This commit is contained in:
commit
e8cd5f0968
3 changed files with 50 additions and 22 deletions
5
.changeset/lemon-bags-happen.md
Normal file
5
.changeset/lemon-bags-happen.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"wrangler-action": patch
|
||||
---
|
||||
|
||||
Handle failures in createGitHubDeployment and createGitHubJobSummary
|
|
@ -1,7 +1,7 @@
|
|||
import { summary } from "@actions/core";
|
||||
import { context, getOctokit } from "@actions/github";
|
||||
import { env } from "process";
|
||||
import { info } from "../utils";
|
||||
import { info, warn } from "../utils";
|
||||
import { OutputEntryPagesDeployment } from "../wranglerArtifactManager";
|
||||
import { WranglerActionConfig } from "../wranglerAction";
|
||||
|
||||
|
@ -95,25 +95,34 @@ export async function createGitHubDeploymentAndJobSummary(
|
|||
pagesArtifactFields.deployment_trigger
|
||||
) {
|
||||
const octokit = getOctokit(config.GITHUB_TOKEN);
|
||||
await Promise.all([
|
||||
createGitHubDeployment({
|
||||
config,
|
||||
octokit,
|
||||
deploymentUrl: pagesArtifactFields.url,
|
||||
productionBranch: pagesArtifactFields.production_branch,
|
||||
environment: pagesArtifactFields.environment,
|
||||
deploymentId: pagesArtifactFields.deployment_id,
|
||||
projectName: pagesArtifactFields.pages_project,
|
||||
}),
|
||||
createJobSummary({
|
||||
commitHash:
|
||||
pagesArtifactFields.deployment_trigger.metadata.commit_hash.substring(
|
||||
0,
|
||||
8,
|
||||
),
|
||||
deploymentUrl: pagesArtifactFields.url,
|
||||
aliasUrl: pagesArtifactFields.alias,
|
||||
}),
|
||||
]);
|
||||
const [createGitHubDeploymentRes, createJobSummaryRes] =
|
||||
await Promise.allSettled([
|
||||
createGitHubDeployment({
|
||||
config,
|
||||
octokit,
|
||||
deploymentUrl: pagesArtifactFields.url,
|
||||
productionBranch: pagesArtifactFields.production_branch,
|
||||
environment: pagesArtifactFields.environment,
|
||||
deploymentId: pagesArtifactFields.deployment_id,
|
||||
projectName: pagesArtifactFields.pages_project,
|
||||
}),
|
||||
createJobSummary({
|
||||
commitHash:
|
||||
pagesArtifactFields.deployment_trigger.metadata.commit_hash.substring(
|
||||
0,
|
||||
8,
|
||||
),
|
||||
deploymentUrl: pagesArtifactFields.url,
|
||||
aliasUrl: pagesArtifactFields.alias,
|
||||
}),
|
||||
]);
|
||||
|
||||
if (createGitHubDeploymentRes.status === "rejected") {
|
||||
warn(config, "Creating Github Deployment failed");
|
||||
}
|
||||
|
||||
if (createJobSummaryRes.status === "rejected") {
|
||||
warn(config, "Creating Github Job summary failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
16
src/utils.ts
16
src/utils.ts
|
@ -1,7 +1,11 @@
|
|||
import { existsSync } from "node:fs";
|
||||
import * as path from "node:path";
|
||||
import semverGt from "semver/functions/gt";
|
||||
import { info as originalInfo, error as originalError } from "@actions/core";
|
||||
import {
|
||||
info as originalInfo,
|
||||
error as originalError,
|
||||
warning as originalWarn,
|
||||
} from "@actions/core";
|
||||
import { WranglerActionConfig } from "./wranglerAction";
|
||||
|
||||
/**
|
||||
|
@ -32,6 +36,16 @@ export function info(
|
|||
}
|
||||
}
|
||||
|
||||
export function warn(
|
||||
config: WranglerActionConfig,
|
||||
message: string,
|
||||
bypass?: boolean,
|
||||
): void {
|
||||
if (!config.QUIET_MODE || bypass) {
|
||||
originalWarn(message);
|
||||
}
|
||||
}
|
||||
|
||||
export function error(
|
||||
config: WranglerActionConfig,
|
||||
message: string,
|
||||
|
|
Loading…
Add table
Reference in a new issue