Fixes #267 Add ActionSkipper

This commit is contained in:
Nick Cipollo
2022-10-27 08:29:12 -04:00
parent 3ac4132803
commit 3bacd9e49a
16 changed files with 297 additions and 17 deletions

27
src/ActionSkipper.ts Normal file
View File

@@ -0,0 +1,27 @@
import {Releases} from "./Releases";
export interface ActionSkipper {
shouldSkip(): Promise<boolean>
}
export class ReleaseActionSkipper {
constructor(private skipIfReleaseExists: boolean,
private releases: Releases,
private tag: string) {
}
async shouldSkip(): Promise<boolean> {
if (!this.skipIfReleaseExists) {
// Bail if skip flag isn't set.
return false;
}
try {
const getResponse = await this.releases.getByTag(this.tag)
return getResponse.data != null
} catch (error: any) {
// There is either no release or something else went wrong. Either way, run the action.
return false;
}
}
}