From 4948de116c6c23aeeb582dbe9d8150a692941945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20T=C3=B6rnqvist?= Date: Wed, 29 Mar 2023 16:15:26 +0200 Subject: [PATCH] Add optional bundle input --- action.yml | 3 +++ index.js | 9 +++++---- src/index.ts | 7 ++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index 61e3f56..6c49035 100644 --- a/action.yml +++ b/action.yml @@ -29,6 +29,9 @@ inputs: description: "The version of Wrangler to use" required: false default: "2" + bundle: + description: "Whether to run bundling on `_worker.js` before deploying" + required: false runs: using: "node16" main: "index.js" diff --git a/index.js b/index.js index 7df67c8..016f6b9 100644 --- a/index.js +++ b/index.js @@ -2071,7 +2071,7 @@ var require_core = __commonJS({ return inputs.map((input) => input.trim()); } exports.getMultilineInput = getMultilineInput; - function getBooleanInput(name, options) { + function getBooleanInput2(name, options) { const trueValue = ["true", "True", "TRUE"]; const falseValue = ["false", "False", "FALSE"]; const val = getInput2(name, options); @@ -2082,7 +2082,7 @@ var require_core = __commonJS({ throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name} Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); } - exports.getBooleanInput = getBooleanInput; + exports.getBooleanInput = getBooleanInput2; function setOutput2(name, value) { const filePath = process.env["GITHUB_OUTPUT"] || ""; if (filePath) { @@ -22070,6 +22070,7 @@ try { const branch = (0, import_core.getInput)("branch", { required: false }); const workingDirectory = (0, import_core.getInput)("workingDirectory", { required: false }); const wranglerVersion = (0, import_core.getInput)("wranglerVersion", { required: false }); + const bundle = (0, import_core.getBooleanInput)("bundle", { required: false }); const getProject = async () => { const response = await (0, import_undici.fetch)( `https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${projectName}`, @@ -22093,8 +22094,8 @@ try { if ${accountId} { $ export CLOUDFLARE_ACCOUNT_ID="${accountId}" } - - $$ npx wrangler@${wranglerVersion} pages publish "${directory}" --project-name="${projectName}" --branch="${branch}" + + $$ npx wrangler@${wranglerVersion} pages publish "${directory}" --project-name="${projectName}" --branch="${branch}" ${bundle ? "" : "--no-bundle"} `; const response = await (0, import_undici.fetch)( `https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${projectName}/deployments`, diff --git a/src/index.ts b/src/index.ts index a63f38e..75c90ba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { getInput, setOutput, setFailed, summary } from "@actions/core"; +import { getInput, getBooleanInput, setOutput, setFailed, summary } from "@actions/core"; import type { Project, Deployment } from "@cloudflare/types"; import { context, getOctokit } from "@actions/github"; import shellac from "shellac"; @@ -17,6 +17,7 @@ try { const branch = getInput("branch", { required: false }); const workingDirectory = getInput("workingDirectory", { required: false }); const wranglerVersion = getInput("wranglerVersion", { required: false }); + const bundle = getBooleanInput("bundle", { required: false }); const getProject = async () => { const response = await fetch( @@ -45,8 +46,8 @@ try { if ${accountId} { $ export CLOUDFLARE_ACCOUNT_ID="${accountId}" } - - $$ npx wrangler@${wranglerVersion} pages publish "${directory}" --project-name="${projectName}" --branch="${branch}" + + $$ npx wrangler@${wranglerVersion} pages publish "${directory}" --project-name="${projectName}" --branch="${branch}" ${bundle ? "" : "--no-bundle"} `; const response = await fetch(