Compare commits

..

16 Commits

Author SHA1 Message Date
github-actions[bot] 05f17c4a69 Automatic compilation 2024-11-06 15:27:40 +00:00
Maximo Guk 6c6d3321ef Merge pull request #320 from cloudflare/changeset-release/main
Version Packages
2024-11-06 11:27:06 -04:00
github-actions[bot] bc61e66e47 Version Packages 2024-11-05 21:26:00 +00:00
Maximo Guk 0e2b86ba21 Merge pull request #319 from cloudflare/maximo/add-changeset-for-wrangler-artifacts-dir
Add missing changeset for using randomUUID for wrangler artifacts dir
2024-11-05 17:25:38 -04:00
Maximo Guk 59c0462940 Add missing changeset for using randomUUID for wrangler artifacts dir 2024-11-05 15:20:12 -06:00
Maximo Guk 4c3f0c27ea Merge pull request #318 from cloudflare/maximo/use-random-uuid-for-wrangler-artifacts-dir
Use random UUID when creating wrangler artifacts output directory
2024-11-05 17:05:58 -04:00
Maximo Guk 4d045615a9 Use random UUID when creating wrangler artifacts output directory 2024-11-05 14:41:27 -06:00
Maximo Guk a7a2388d7b Merge pull request #313 from cloudflare/changeset-release/main
Version Packages
2024-11-04 11:31:39 -04:00
github-actions[bot] 2171bbdd69 Version Packages 2024-11-01 18:40:47 +00:00
Maximo Guk 4f4ff59d17 Merge pull request #312 from cloudflare/maximo/unrevert-add-parity-with-wrangler-action
Unrevert add parity with wrangler action
2024-11-01 15:40:25 -03:00
Maximo Guk 122ee5cf5b Moves wrangler output to tmpdir rather than /opt/ since /opt/ is owned by root.
- Github self hosted runners may not have permissions to write to /opt/

- Also fallsback to trying to extract the deployment-url and deployment-alias-url from stdout when WRANGLER_OUTPUT_DIR is not specified
2024-11-01 13:29:38 -05:00
Maximo Guk 44d79edf44 Reapply "Add parity with pages-action for pages deploy outputs"
This reverts commit 10d5b9c1c1.
2024-10-31 00:47:44 -05:00
Maximo Guk b2be7abbfc Merge pull request #310 from cloudflare/changeset-release/main
Version Packages
2024-10-24 11:56:05 -03:00
github-actions[bot] b7158dc9a4 Version Packages 2024-10-24 14:49:52 +00:00
Maximo Guk 43767e73de Merge pull request #309 from cloudflare/maximo/revert-add-parity-with-pages-action
Revert add parity with pages action
2024-10-24 11:48:43 -03:00
Maximo Guk 10d5b9c1c1 Revert "Add parity with pages-action for pages deploy outputs"
This reverts commit 3ec7f8943e.
2024-10-24 08:45:19 -05:00
2 changed files with 50 additions and 25 deletions
+6 -2
View File
@@ -51,5 +51,9 @@ 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 Workers or Pages deployment, this can be the URL of the deployment alias (if it exists) - needs wrangler >= 3.78.0"
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:
description: "If the command was a Pages deployment, this will be the ID of the deployment - needs wrangler >= 3.81.0"
pages-environment:
description: "If the command was a Pages deployment, this will be the environment of the deployment - needs wrangler >= 3.81.0"
+44 -23
View File
@@ -33053,6 +33053,10 @@ async function getDetailedPagesDeployOutput(artifactDirectory) {
return null;
}
// EXTERNAL MODULE: external "path"
var external_path_ = __nccwpck_require__(1017);
// EXTERNAL MODULE: external "os"
var external_os_ = __nccwpck_require__(2037);
;// CONCATENATED MODULE: ./src/index.ts
@@ -33061,6 +33065,8 @@ async function getDetailedPagesDeployOutput(artifactDirectory) {
const DEFAULT_WRANGLER_VERSION = "3.81.0";
/**
* A configuration object that contains all the inputs & immutable state for the action.
@@ -33077,6 +33083,7 @@ const config = {
COMMANDS: (0,core.getMultilineInput)("command"),
QUIET_MODE: (0,core.getBooleanInput)("quiet"),
PACKAGE_MANAGER: (0,core.getInput)("packageManager"),
WRANGLER_OUTPUT_DIR: `${(0,external_path_.join)((0,external_os_.tmpdir)(), `wranglerArtifacts-${crypto.randomUUID()}`)}`,
};
const packageManager = getPackageManager(config.PACKAGE_MANAGER, {
workingDirectory: config.workingDirectory,
@@ -33264,6 +33271,22 @@ async function uploadSecrets() {
endGroup();
}
}
// fallback to trying to extract the deployment-url and pages-deployment-alias-url from stdout for wranglerVersion < 3.81.0
function extractDeploymentUrlsFromStdout(stdOut) {
let deploymentUrl = "";
let aliasUrl = "";
// Try to extract the deployment URL
const deploymentUrlMatch = stdOut.match(/https?:\/\/[a-zA-Z0-9-./]+/);
if (deploymentUrlMatch && deploymentUrlMatch[0]) {
deploymentUrl = deploymentUrlMatch[0].trim();
}
// And also try to extract the alias URL (since wrangler@3.78.0)
const aliasUrlMatch = stdOut.match(/alias URL: (https?:\/\/[a-zA-Z0-9-./]+)/);
if (aliasUrlMatch && aliasUrlMatch[1]) {
aliasUrl = aliasUrlMatch[1].trim();
}
return { deploymentUrl, aliasUrl };
}
async function wranglerCommands() {
startGroup("🚀 Running Wrangler Commands");
try {
@@ -33292,9 +33315,8 @@ async function wranglerCommands() {
// Used for saving the wrangler output
let stdOut = "";
let stdErr = "";
// Construct the options for the exec command
const wranglerOutputDir = "/opt/wranglerArtifacts";
process.env.WRANGLER_OUTPUT_FILE_DIRECTORY = wranglerOutputDir;
// set WRANGLER_OUTPUT_FILE_DIRECTORY env for exec
process.env.WRANGLER_OUTPUT_FILE_DIRECTORY = config.WRANGLER_OUTPUT_DIR;
const options = {
cwd: config["workingDirectory"],
silent: config["QUIET_MODE"],
@@ -33314,33 +33336,32 @@ async function wranglerCommands() {
(0,core.setOutput)("command-stderr", stdErr);
// Check if this command is a workers deployment
if (command.startsWith("deploy") || command.startsWith("publish")) {
// Try to extract the deployment URL
let deploymentUrl = "";
const deploymentUrlMatch = stdOut.match(/https?:\/\/[a-zA-Z0-9-./]+/);
if (deploymentUrlMatch && deploymentUrlMatch[0]) {
deploymentUrl = deploymentUrlMatch[0].trim();
(0,core.setOutput)("deployment-url", deploymentUrl);
}
// And also try to extract the alias URL (since wrangler@3.78.0)
const aliasUrlMatch = stdOut.match(/alias URL: (https?:\/\/[a-zA-Z0-9-./]+)/);
if (aliasUrlMatch && aliasUrlMatch.length == 2 && aliasUrlMatch[1]) {
const aliasUrl = aliasUrlMatch[1].trim();
(0,core.setOutput)("deployment-alias-url", aliasUrl);
}
const { deploymentUrl, aliasUrl } = extractDeploymentUrlsFromStdout(stdOut);
(0,core.setOutput)("deployment-url", deploymentUrl);
// DEPRECATED: deployment-alias-url in favour of pages-deployment-alias, drop in next wrangler-action major version change
(0,core.setOutput)("deployment-alias-url", aliasUrl);
(0,core.setOutput)("pages-deployment-alias-url", aliasUrl);
}
// Check if this command is a pages deployment
if (command.startsWith("pages publish") ||
command.startsWith("pages deploy")) {
const pagesArtifactFields = await getDetailedPagesDeployOutput(wranglerOutputDir);
const pagesArtifactFields = await getDetailedPagesDeployOutput(config.WRANGLER_OUTPUT_DIR);
if (pagesArtifactFields) {
(0,core.setOutput)("id", pagesArtifactFields.deployment_id);
(0,core.setOutput)("url", pagesArtifactFields.url);
// To ensure parity with pages-action, display url for alias if there is no alias
(0,core.setOutput)("alias", pagesArtifactFields.alias);
(0,core.setOutput)("environment", pagesArtifactFields.environment);
(0,core.setOutput)("deployment-url", pagesArtifactFields.url);
// DEPRECATED: deployment-alias-url in favour of pages-deployment-alias, drop in next wrangler-action major version change
(0,core.setOutput)("deployment-alias-url", pagesArtifactFields.alias);
(0,core.setOutput)("pages-deployment-alias-url", pagesArtifactFields.alias);
(0,core.setOutput)("pages-deployment-id", pagesArtifactFields.deployment_id);
(0,core.setOutput)("pages-environment", pagesArtifactFields.environment);
}
else {
info("No fields available for output. Have you updated wrangler to version >=3.81.0?");
info("Unable to find a WRANGLER_OUTPUT_DIR, environment and id fields will be unavailable for output. Have you updated wrangler to version >=3.81.0?");
// DEPRECATED: deployment-alias-url in favour of pages-deployment-alias, drop in next wrangler-action major version change
const { deploymentUrl, aliasUrl } = extractDeploymentUrlsFromStdout(stdOut);
(0,core.setOutput)("deployment-url", deploymentUrl);
// DEPRECATED: deployment-alias-url in favour of pages-deployment-alias, drop in next wrangler-action major version change
(0,core.setOutput)("deployment-alias-url", aliasUrl);
(0,core.setOutput)("pages-deployment-alias-url", aliasUrl);
}
}
}