Skip to content

Commit

Permalink
Add artifact upload error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Cipollo committed Jan 3, 2020
1 parent b0c22f0 commit f367946
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
16 changes: 15 additions & 1 deletion lib/ArtifactUploader.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
class GithubArtifactUploader {
constructor(releases) {
this.releases = releases;
}
uploadArtifacts(artifacts, uploadUrl) {
return __awaiter(this, void 0, void 0, function* () {
artifacts.forEach((artifact) => __awaiter(this, void 0, void 0, function* () {
yield this.releases.uploadArtifact(uploadUrl, artifact.contentLength, artifact.contentType, artifact.readFile(), artifact.name);
try {
yield this.releases.uploadArtifact(uploadUrl, artifact.contentLength, artifact.contentType, artifact.readFile(), artifact.name);
}
catch (error) {
const message = `Failed to upload artifact ${artifact.name}. Does it already exist?`;
core.warning(message);
}
}));
});
}
Expand Down
16 changes: 11 additions & 5 deletions src/ArtifactUploader.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as core from '@actions/core';
import { Artifact } from "./Artifact";
import { Releases } from "./Releases";

Expand All @@ -14,11 +15,16 @@ export class GithubArtifactUploader implements ArtifactUploader {

async uploadArtifacts(artifacts: Artifact[], uploadUrl: string) {
artifacts.forEach(async artifact => {
await this.releases.uploadArtifact(uploadUrl,
artifact.contentLength,
artifact.contentType,
artifact.readFile(),
artifact.name)
try {
await this.releases.uploadArtifact(uploadUrl,
artifact.contentLength,
artifact.contentType,
artifact.readFile(),
artifact.name)
} catch(error) {
const message = `Failed to upload artifact ${artifact.name}. Does it already exist?`
core.warning(message)
}
});
}
}

0 comments on commit f367946

Please sign in to comment.