Skip to content

Commit

Permalink
Merge pull request #951 from chromaui/todd/fix-gha-array-inputs
Browse files Browse the repository at this point in the history
Properly handle GitHub Action inputs that can have multiple values
  • Loading branch information
ghengeveld committed Mar 20, 2024
2 parents 3b5a21c + 2593eba commit 55e8043
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions action-src/main.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { error, getInput, setFailed, setOutput } from '@actions/core';
import { error, getInput, getMultilineInput, setFailed, setOutput } from '@actions/core';
import { context } from '@actions/github';
import path from 'path';

import { run as runNode } from '../node-src';

const maybe = (a: string, b: any = undefined) => {
const maybe = (a: string | string[], b: any = undefined) => {
if (!a) {
return b;
}

if (Array.isArray(a)) {
return a;
}

try {
return JSON.parse(a);
} catch (e) {
Expand Down Expand Up @@ -100,15 +104,15 @@ async function run() {
const dryRun = getInput('dryRun');
const exitOnceUploaded = getInput('exitOnceUploaded');
const exitZeroOnChanges = getInput('exitZeroOnChanges');
const externals = getInput('externals');
const externals = getMultilineInput('externals');
const fileHashing = getInput('fileHashing');
const forceRebuild = getInput('forceRebuild');
const ignoreLastBuildOnBranch = getInput('ignoreLastBuildOnBranch');
const logFile = getInput('logFile');
const only = getInput('only');
const onlyChanged = getInput('onlyChanged');
const onlyStoryFiles = getInput('onlyStoryFiles');
const onlyStoryNames = getInput('onlyStoryNames');
const onlyStoryFiles = getMultilineInput('onlyStoryFiles');
const onlyStoryNames = getMultilineInput('onlyStoryNames');
const playwright = getInput('playwright');
const preserveMissing = getInput('preserveMissing');
const projectToken = getInput('projectToken') || getInput('appCode'); // backwards compatibility
Expand All @@ -119,7 +123,7 @@ async function run() {
const storybookConfigDir = getInput('storybookConfigDir');
const storybookLogFile = getInput('storybookLogFile');
const traceChanged = getInput('traceChanged');
const untraced = getInput('untraced');
const untraced = getMultilineInput('untraced');
const uploadMetadata = getInput('uploadMetadata');
const workingDir = getInput('workingDir') || getInput('workingDirectory');
const zip = getInput('zip');
Expand Down

0 comments on commit 55e8043

Please sign in to comment.