Skip to content

Commit

Permalink
Merge pull request #212 from thelfensdrfer/next
Browse files Browse the repository at this point in the history
Added monorepo support
  • Loading branch information
ndelangen committed Dec 15, 2020
2 parents d37a1b8 + 128039c commit e0eab6a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
30 changes: 16 additions & 14 deletions action.yml
Expand Up @@ -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"
Expand All @@ -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
6 changes: 5 additions & 1 deletion action/main.js
Expand Up @@ -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"));
Expand Down Expand Up @@ -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:
Expand All @@ -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');
Expand All @@ -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),
Expand Down
4 changes: 4 additions & 0 deletions action/main.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
Expand All @@ -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),
Expand Down

0 comments on commit e0eab6a

Please sign in to comment.