From 00379112d29bd1e9b5b19722cc4719870c645fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Helfensd=C3=B6rfer?= Date: Fri, 20 Nov 2020 13:09:29 +0100 Subject: [PATCH 1/6] Added monorepo support --- action.yml | 30 ++++++++++++++++-------------- action/main.js | 6 +++++- action/main.ts | 4 ++++ 3 files changed, 25 insertions(+), 15 deletions(-) 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), From 88b89a923571001bca11c454dadfe8937a2a0fa3 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 15 Dec 2020 12:43:41 +0100 Subject: [PATCH 2/6] fix fetch depth --- .github/workflows/action-run.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/action-run.yml b/.github/workflows/action-run.yml index fe4686750..0442cdba0 100755 --- a/.github/workflows/action-run.yml +++ b/.github/workflows/action-run.yml @@ -12,6 +12,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - run: yarn && yarn build && yarn build-storybook - uses: ./ with: From 859ae3689b6a0783522afe2213b0cf7706cd2c55 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 15 Dec 2020 12:48:02 +0100 Subject: [PATCH 3/6] fix development-like action --- .github/workflows/action-run.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/action-run.yml b/.github/workflows/action-run.yml index 0442cdba0..aa3a0f26f 100755 --- a/.github/workflows/action-run.yml +++ b/.github/workflows/action-run.yml @@ -14,7 +14,9 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 0 - - run: yarn && yarn build && yarn build-storybook + - run: yarn + - run: yarn build + - run: yarn build-storybook - uses: ./ with: projectToken: 5oy3iw6rkio From 1b9c6c38444f7e73308b0aaa8e6e3f8b0092a1ee Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 15 Dec 2020 12:56:27 +0100 Subject: [PATCH 4/6] no message --- .github/workflows/action-run.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/action-run.yml b/.github/workflows/action-run.yml index aa3a0f26f..08c44112d 100755 --- a/.github/workflows/action-run.yml +++ b/.github/workflows/action-run.yml @@ -1,7 +1,6 @@ name: "self test development-like" on: pull_request: - pull_request_target: pull_request_review: push: branches: From 23e2c0ef69344fb2c72f1cdf700cbd9db338b0cd Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 15 Dec 2020 13:02:10 +0100 Subject: [PATCH 5/6] no message --- .github/workflows/action-run.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/action-run.yml b/.github/workflows/action-run.yml index 08c44112d..9f687c2cd 100755 --- a/.github/workflows/action-run.yml +++ b/.github/workflows/action-run.yml @@ -1,10 +1,6 @@ name: "self test development-like" on: - pull_request: - pull_request_review: push: - branches: - - master jobs: test: From ea44ff201c809905ac74b0d7f2077723bcab9c9d Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 15 Dec 2020 13:11:56 +0100 Subject: [PATCH 6/6] wip --- .github/workflows/action-run.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/action-run.yml b/.github/workflows/action-run.yml index 9f687c2cd..cf6d49316 100755 --- a/.github/workflows/action-run.yml +++ b/.github/workflows/action-run.yml @@ -6,9 +6,7 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 + - uses: actions/checkout@v1 - run: yarn - run: yarn build - run: yarn build-storybook