diff --git a/action.yml b/action.yml index 85bec5f3b..f1ac02b3c 100755 --- a/action.yml +++ b/action.yml @@ -8,31 +8,33 @@ branding: inputs: token: description: "Your github token" - projectToken: + projectToken: description: "Your chromatic project token" - appCode: + workingDir: + description: "Working directory for the package.json file" + appCode: description: "Deprecated, please use projectToken instead" - buildScriptName: + buildScriptName: description: "The npm script that builds your Storybook [build-storybook]" - doNotStart: + doNotStart: description: "Do not attempt to start or build; use if your Storybook is already running" - exec: + exec: description: "Alternatively, a full command to run to start your storybook" - scriptName: + scriptName: description: "The npm script that starts your Storybook [storybook]" - storybookBuildDir: + storybookBuildDir: description: "Provide a directory with your built storybook; use if you have already built your storybook" - storybookCa: + storybookCa: description: "Use if Storybook is running on https (auto detected from -s, if set)" - storybookCert: + storybookCert: description: "Use if Storybook is running on https (auto detected from -s, if set)" - storybookHttps: + storybookHttps: description: "Use if Storybook is running on https (auto detected from -s, if set)" - storybookKey: + storybookKey: description: "Use if Storybook is running on https (auto detected from -s, if set)" - storybookPort: + storybookPort: description: "What port is your Storybook running on (auto detected from -s, if set)" - storybookUrl: + storybookUrl: description: "Storybook is already running at (external) url (implies -S)" preserveMissing: description: "Pass the baselines forward and treat all missing stories as “preserved” without re-capturing them" @@ -45,6 +47,6 @@ inputs: exitOnceUploaded: description: "Exit with 0 once the built version has been sent to chromatic: boolean or branchname" -runs: +runs: main: action/register.js using: node12 diff --git a/action/main.js b/action/main.js index 390932000..bd2ad6859 100644 --- a/action/main.js +++ b/action/main.js @@ -55,6 +55,7 @@ var github_1 = require("@actions/github"); var jsonfile_1 = require("jsonfile"); var pkg_up_1 = __importDefault(require("pkg-up")); var uuid_1 = require("uuid"); +var path_1 = __importDefault(require("path")); var getEnv_1 = __importDefault(require("../bin/lib/getEnv")); var log_1 = require("../bin/lib/log"); var parseArgs_1 = __importDefault(require("../bin/lib/parseArgs")); @@ -140,7 +141,7 @@ function runChromatic(options) { } function run() { return __awaiter(this, void 0, void 0, function () { - var commit, branch, sha, projectToken, buildScriptName, scriptName, exec, skip, doNotStart, storybookPort, storybookUrl, storybookBuildDir, storybookHttps, storybookCert, storybookKey, storybookCa, preserveMissing, autoAcceptChanges, allowConsoleErrors, exitZeroOnChanges, exitOnceUploaded, ignoreLastBuildOnBranch, chromatic, _a, url, code, e_1; + var commit, branch, sha, projectToken, workingDir, buildScriptName, scriptName, exec, skip, doNotStart, storybookPort, storybookUrl, storybookBuildDir, storybookHttps, storybookCert, storybookKey, storybookCa, preserveMissing, autoAcceptChanges, allowConsoleErrors, exitZeroOnChanges, exitOnceUploaded, ignoreLastBuildOnBranch, chromatic, _a, url, code, e_1; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -153,6 +154,7 @@ function run() { case 1: _b.trys.push([1, 3, , 4]); projectToken = core_1.getInput('projectToken') || core_1.getInput('appCode'); + workingDir = core_1.getInput('workingDir'); buildScriptName = core_1.getInput('buildScriptName'); scriptName = core_1.getInput('scriptName'); exec = core_1.getInput('exec'); @@ -173,8 +175,10 @@ function run() { ignoreLastBuildOnBranch = core_1.getInput('ignoreLastBuildOnBranch'); process.env.CHROMATIC_SHA = sha; process.env.CHROMATIC_BRANCH = branch; + process.chdir(path_1["default"].join(process.cwd(), workingDir || '')); chromatic = runChromatic({ projectToken: projectToken, + workingDir: maybe(workingDir), buildScriptName: maybe(buildScriptName), scriptName: maybe(scriptName), exec: maybe(exec), diff --git a/action/main.ts b/action/main.ts index 377532cac..b300c56c9 100755 --- a/action/main.ts +++ b/action/main.ts @@ -3,6 +3,7 @@ import { context } from '@actions/github'; import { readFile } from 'jsonfile'; import pkgUp from 'pkg-up'; import { v4 as uuid } from 'uuid'; +import path from 'path'; import getEnv from '../bin/lib/getEnv'; import { createLogger } from '../bin/lib/log'; @@ -98,6 +99,7 @@ async function run() { try { const projectToken = getInput('projectToken') || getInput('appCode'); // backwards compatibility + const workingDir = getInput('workingDir'); const buildScriptName = getInput('buildScriptName'); const scriptName = getInput('scriptName'); const exec = getInput('exec'); @@ -119,9 +121,11 @@ async function run() { process.env.CHROMATIC_SHA = sha; process.env.CHROMATIC_BRANCH = branch; + process.chdir(path.join(process.cwd(), workingDir || '')); const chromatic = runChromatic({ projectToken, + workingDir: maybe(workingDir), buildScriptName: maybe(buildScriptName), scriptName: maybe(scriptName), exec: maybe(exec),