From 95b8faa4883d606624d38e70507a7e9f8ab2257b Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Fri, 24 Jul 2020 11:07:43 +0900 Subject: [PATCH] Add handling for additional workflow dispatch errors --- dist/index.js | 6 +++++- docs/workflow-dispatch.md | 2 ++ src/main.ts | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index d8f430f..7891726 100644 --- a/dist/index.js +++ b/dist/index.js @@ -647,8 +647,12 @@ function run() { catch (error) { core.debug(util_1.inspect(error)); const message = error.message; + // Handle validation errors from workflow dispatch if (message == 'Unexpected inputs provided' || - (message.startsWith('Required input') && message.endsWith('not provided'))) { + (message.startsWith('Required input') && + message.endsWith('not provided')) || + message.startsWith('No ref found for:') || + message == `Workflow does not have 'workflow_dispatch' trigger`) { core.setOutput('error-message', message); core.warning(message); } diff --git a/docs/workflow-dispatch.md b/docs/workflow-dispatch.md index 32376d7..a350075 100644 --- a/docs/workflow-dispatch.md +++ b/docs/workflow-dispatch.md @@ -97,6 +97,8 @@ When creating the [workflow_dispatch](https://docs.github.com/en/actions/referen - `Required input '...' not provided` - A required input for the workflow was not supplied as a named argument. - `Unexpected inputs provided` - Named arguments were supplied that are not defined as workflow inputs. +- `No ref found for: ...` - The supplied `ref` does not exist in the target repository. +- `Workflow does not have 'workflow_dispatch' trigger` - The target workflow doesn't define `on: workflow_dispatch`, OR, the supplied `ref` doesn't contain the target workflow. The `error-message` output can be used to provide feedback to the user as follows. Note that the action step needs an `id` to access outputs. diff --git a/src/main.ts b/src/main.ts index f507cf0..313c6d4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -192,9 +192,13 @@ async function run(): Promise { } catch (error) { core.debug(inspect(error)) const message: string = error.message + // Handle validation errors from workflow dispatch if ( message == 'Unexpected inputs provided' || - (message.startsWith('Required input') && message.endsWith('not provided')) + (message.startsWith('Required input') && + message.endsWith('not provided')) || + message.startsWith('No ref found for:') || + message == `Workflow does not have 'workflow_dispatch' trigger` ) { core.setOutput('error-message', message) core.warning(message)