Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle GitHub Action inputs that can have multiple values #951

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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