Fix bugs found in E2E testing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Inputs } from "./Inputs";
|
||||
import { Releases } from "./Releases";
|
||||
import { basename } from "path";
|
||||
import { readFileSync } from "fs";
|
||||
|
||||
export class Action {
|
||||
private inputs: Inputs
|
||||
@@ -21,12 +22,13 @@ export class Action {
|
||||
)
|
||||
|
||||
if (this.inputs.artifact) {
|
||||
const artifactData = this.inputs.readArtifact()
|
||||
await this.releases.uploadArtifact(
|
||||
createResult.data.assets_url,
|
||||
createResult.data.upload_url,
|
||||
this.inputs.artifactContentLength,
|
||||
this.inputs.artifactContentType,
|
||||
this.inputs.artifact,
|
||||
basename(this.inputs.artifact)
|
||||
artifactData,
|
||||
this.inputs.artifactName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import * as core from '@actions/core';
|
||||
import { Context } from "@actions/github/lib/context";
|
||||
import { readFileSync, statSync } from 'fs';
|
||||
import { basename } from 'path';
|
||||
|
||||
export interface Inputs {
|
||||
readonly artifact: string
|
||||
readonly artifactName: string
|
||||
readonly artifactContentType: string
|
||||
readonly artifactContentLength: number
|
||||
readonly body: string
|
||||
@@ -12,6 +14,8 @@ export interface Inputs {
|
||||
readonly name: string
|
||||
readonly tag: string
|
||||
readonly token: string
|
||||
|
||||
readArtifact(): Buffer
|
||||
}
|
||||
|
||||
export class CoreInputs implements Inputs {
|
||||
@@ -25,6 +29,10 @@ export class CoreInputs implements Inputs {
|
||||
return core.getInput('artifact')
|
||||
}
|
||||
|
||||
get artifactName(): string {
|
||||
return basename(this.artifact)
|
||||
}
|
||||
|
||||
get artifactContentType(): string {
|
||||
const type = core.getInput('artifactContentType')
|
||||
if(type) {
|
||||
@@ -89,6 +97,10 @@ export class CoreInputs implements Inputs {
|
||||
return core.getInput('token', { required: true })
|
||||
}
|
||||
|
||||
readArtifact(): Buffer {
|
||||
return readFileSync(this.artifact)
|
||||
}
|
||||
|
||||
stringFromFile(path: string): string {
|
||||
return readFileSync(path, 'utf-8')
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export interface Releases {
|
||||
assetUrl: string,
|
||||
contentLength: number,
|
||||
contentType: string,
|
||||
file: string,
|
||||
file: string | object,
|
||||
name: string
|
||||
): Promise<Response<AnyResponse>>
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export class GithubReleases implements Releases{
|
||||
assetUrl: string,
|
||||
contentLength: number,
|
||||
contentType: string,
|
||||
file: string,
|
||||
file: string | object,
|
||||
name: string
|
||||
): Promise<Response<AnyResponse>> {
|
||||
return this.git.repos.uploadReleaseAsset({
|
||||
|
||||
Reference in New Issue
Block a user