Skip to content

Commit

Permalink
SetFailed on error
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolay Matrosov committed Jul 28, 2022
1 parent 65d73d3 commit ad95046
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 26 deletions.
14 changes: 3 additions & 11 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yc-actions-yc-sls-function",
"version": "2.0.0",
"version": "2.1.0",
"description": "GitHub Action to deploy Serverless Function to Yandex Cloud.",
"main": "lib/main.js",
"scripts": {
Expand Down
15 changes: 2 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
ListFunctionsRequest,
} from '@yandex-cloud/nodejs-sdk/dist/generated/yandex/cloud/serverless/functions/v1/function_service';
import {Package} from '@yandex-cloud/nodejs-sdk/dist/generated/yandex/cloud/serverless/functions/v1/function';
import {Operation} from '@yandex-cloud/nodejs-sdk/dist/generated/yandex/cloud/operation/operation';
import {StorageServiceImpl} from './storage';
import {StorageObject} from './storage/storage-object';
import {IIAmCredentials} from '@yandex-cloud/nodejs-sdk/dist/types';
Expand Down Expand Up @@ -155,17 +154,6 @@ async function run(): Promise<void> {
}
}

function handleOperationError(operation: Operation): void {
if (operation.error) {
const details = operation.error?.details;
if (details) {
throw Error(`${operation.error.code}: ${operation.error.message} (${details.join(', ')})`);
}

throw Error(`${operation.error.code}: ${operation.error.message}`);
}
}

async function createFunctionVersion(
session: Session,
functionId: string,
Expand Down Expand Up @@ -212,7 +200,6 @@ async function createFunctionVersion(
const operation = await functionService.createVersion(request);
await waitForOperation(operation, session);

handleOperationError(operation);
core.info('Operation complete');
let metadata;
if (operation.metadata) {
Expand All @@ -222,6 +209,8 @@ async function createFunctionVersion(
throw new Error('Failed to create function version');
}
core.setOutput('version-id', metadata.functionVersionId);
} catch (error) {
core.setFailed((error as {description: string}).description);
} finally {
core.endGroup();
}
Expand Down

0 comments on commit ad95046

Please sign in to comment.