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

fix: action failure status #151

Merged
merged 2 commits into from
Jan 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ msg := ""
IMAGE_NAME := actions_hugo_dev:latest
NODE_VERSION := $(shell cat ./.nvmrc)
DOCKER_BUILD := docker build . -t $(IMAGE_NAME) --build-arg NODE_VERSION=$(NODE_VERSION)
DOCKER_RUN := docker run --rm -i -t -v ${PWD}:/repo -v ~/.gitconfig:/etc/gitconfig $(IMAGE_NAME)
DOCKER_RUN := docker run --rm -i -t -v ${PWD}:/repo -v ~/.gitconfig:/root/.gitconfig $(IMAGE_NAME)


.PHONY: build
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import * as core from '@actions/core';
import * as main from './main';

main.run();
try {
main.run();
} catch (e) {
core.setFailed(`Action failed with error ${e}`);
}
37 changes: 16 additions & 21 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,23 @@ export async function showVersion(
}

export async function run(): Promise<ActionResult> {
try {
const toolVersion: string = core.getInput('hugo-version');
let installVersion = '';

let result: ActionResult = {
exitcode: 0,
output: ''
};

if (toolVersion === '' || toolVersion === 'latest') {
installVersion = await getLatestVersion(Tool.Org, Tool.Repo, 'brew');
} else {
installVersion = toolVersion;
}
const toolVersion: string = core.getInput('hugo-version');
let installVersion = '';

core.info(`${Tool.Name} version: ${installVersion}`);
await installer(installVersion);
result = await showVersion(Tool.CmdName, [Tool.CmdOptVersion]);
let result: ActionResult = {
exitcode: 0,
output: ''
};

return result;
} catch (e) {
core.setFailed(`Action failed with error ${e}`);
throw e;
if (toolVersion === '' || toolVersion === 'latest') {
installVersion = await getLatestVersion(Tool.Org, Tool.Repo, 'brew');
} else {
installVersion = toolVersion;
}

core.info(`${Tool.Name} version: ${installVersion}`);
await installer(installVersion);
result = await showVersion(Tool.CmdName, [Tool.CmdOptVersion]);

return result;
}