diff --git a/entrypoint.sh b/entrypoint.sh index c2383833..069228da 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +set -e + code-suggester $INPUT_COMMAND \ --upstream-repo="$INPUT_UPSTREAM_REPO" \ --upstream-owner="$INPUT_UPSTREAM_OWNER" \ diff --git a/src/bin/code-suggester.ts b/src/bin/code-suggester.ts index 0a106a86..61ed1950 100644 --- a/src/bin/code-suggester.ts +++ b/src/bin/code-suggester.ts @@ -16,6 +16,7 @@ import * as yargs from 'yargs'; import {CREATE_PR_COMMAND, main} from './workflow'; +import {logger} from '../logger'; // tslint:disable:no-unused-expression // yargs actually is a used expression. TS-lint does not detect it. @@ -103,4 +104,10 @@ yargs /** * Parse yargs, get change object, invoke framework-core library! */ -main(); +main().catch(err => { + logger.error(err); + /* eslint-disable no-process-exit */ + // If just rethrow, the application exists with code 0. + // Need exit code 1 to fail GitHub Actions step if the process fails. + process.exit(1); +});