diff --git a/.changeset/breezy-guests-tie.md b/.changeset/breezy-guests-tie.md new file mode 100644 index 00000000..25737af9 --- /dev/null +++ b/.changeset/breezy-guests-tie.md @@ -0,0 +1,5 @@ +--- +"wrangler-action": minor +--- + +Make version preview alias URL available in outputs via `deployment-alias-url` diff --git a/.changeset/swift-shrimps-beg.md b/.changeset/swift-shrimps-beg.md new file mode 100644 index 00000000..f16dad71 --- /dev/null +++ b/.changeset/swift-shrimps-beg.md @@ -0,0 +1,5 @@ +--- +"wrangler-action": minor +--- + +Output `version-id` for version uploads diff --git a/action.yml b/action.yml index a6ccf5a5..229c6785 100644 --- a/action.yml +++ b/action.yml @@ -54,6 +54,10 @@ outputs: description: "The error output of the Wrangler command (comes from stderr)" deployment-url: description: "If the command was a Workers or Pages deployment, this will be the URL of the deployment" + deployment-alias-url: + description: "If the command was a Worker deployment, this will be the alias (if it exists)" + version-id: + description: "If the command was a Worker deployment, this will be the deployment id" pages-deployment-alias-url: description: "If the command was a Pages deployment, this will be the URL of the deployment alias (if it exists) - needs wrangler >= 3.78.0" pages-deployment-id: diff --git a/src/commandOutputParsing.ts b/src/commandOutputParsing.ts index 6ddfb5a7..2cfded8f 100644 --- a/src/commandOutputParsing.ts +++ b/src/commandOutputParsing.ts @@ -112,6 +112,8 @@ function handleVersionsUploadOutputEntry( versionsOutputEntry: OutputEntryVersionUpload, ) { setOutput("deployment-url", versionsOutputEntry.preview_url); + setOutput("deployment-alias-url", versionsOutputEntry.preview_alias_url); + setOutput("version-id", versionsOutputEntry.version_id); } /** diff --git a/src/wranglerArtifactManager.test.ts b/src/wranglerArtifactManager.test.ts index 962bb337..b45486cd 100644 --- a/src/wranglerArtifactManager.test.ts +++ b/src/wranglerArtifactManager.test.ts @@ -141,7 +141,7 @@ describe("wranglerArtifactsManager", () => { testOutputDir: { "wrangler-output-2024-10-17_18-48-40_463-2e6e83.json": ` {"version": 1, "type":"wrangler-session", "wrangler_version":"3.81.0", "command_line_args":["what's up"], "log_file_path": "/here"} - {"version": 1, "type":"version-upload", "preview_url": "https://example.com"}`, + {"version": 1, "type":"version-upload", "preview_url": "https://example.com", "preview_alias_url":"https://example.alias", "version_id": "123"}`, "not-wrangler-output.json": "test", }, }); @@ -155,6 +155,8 @@ describe("wranglerArtifactsManager", () => { version: 1, type: "version-upload", preview_url: "https://example.com", + preview_alias_url: "https://example.alias", + version_id: "123", }); }), it("Skips artifact entries that are not parseable", async () => { diff --git a/src/wranglerArtifactManager.ts b/src/wranglerArtifactManager.ts index 9bc29ede..f14bcc30 100644 --- a/src/wranglerArtifactManager.ts +++ b/src/wranglerArtifactManager.ts @@ -47,6 +47,8 @@ const OutputEntryVersionUpload = OutputEntryBase.merge( type: z.literal("version-upload"), /** The preview URL associated with this version upload */ preview_url: z.string().optional(), + preview_alias_url: z.string().optional(), + version_id: z.string().optional(), }), );