Add token test.

This commit is contained in:
Nick Cipollo
2019-08-26 12:15:12 -04:00
parent 0412ec85b5
commit 488aa36d03
4 changed files with 58 additions and 4 deletions

29
src/Inputs.ts Normal file
View File

@@ -0,0 +1,29 @@
import * as core from '@actions/core';
import { Context } from "@actions/github/lib/context";
export class Inputs {
private context: Context
constructor(context: Context) {
this.context = context;
}
get token(): string {
return core.getInput('token', {required: true});
}
get tag() : string {
const tag = core.getInput('tag');
if(tag != null) {
return tag;
}
const ref = this.context.ref;
const tagPath = "refs/tags/";
if(ref.startsWith(tagPath)) {
return ref.substr(0, tagPath.length);
}
throw Error("No tag found in ref or input!")
}
}