Skip to content

Commit

Permalink
Update dist file
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Sep 6, 2020
1 parent 7e10c2a commit dc8f8e2
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ function main() {
const updater = new update_1.Updater(options);
updater
.updateFiles(pathsToUpdate)
.then(({ commitSha, branch }) => {
if (commitSha === null) {
.then((updateResult) => {
if (updateResult === null) {
core_1.info('No files to update');
return;
}
const { commitSha, branch } = updateResult;
core_1.setOutput('commit-sha', commitSha);
const shortSha = commitSha.slice(0, 7);
core_1.info(`Pushed ${shortSha} to ${branch}`);
Expand All @@ -55,6 +56,7 @@ exports.Updater = void 0;
const fs_1 = __webpack_require__(747);
const util_1 = __webpack_require__(669);
const github_1 = __webpack_require__(438);
const util_2 = __webpack_require__(731);
const readFileAsync = util_1.promisify(fs_1.readFile);
class Updater {
constructor(options) {
Expand Down Expand Up @@ -82,12 +84,9 @@ class Updater {
return data.sha;
}
async createTree(branch, filePaths, base_tree) {
const promises = Promise.all(filePaths.map((filePath) => {
const tree = (await Promise.all(filePaths.map((filePath) => {
return this.createTreeItem(filePath, branch);
}));
const tree = (await promises).filter((change) => {
return change !== null;
});
}))).filter(util_2.isNotNull);
if (tree.length === 0) {
return null;
}
Expand All @@ -98,7 +97,7 @@ class Updater {
async createTreeItem(filePath, branch) {
const remoteFile = await this.getRemoteContents(filePath, branch);
const localContents = await this.getLocalContents(filePath);
const remoteContents = remoteFile.content;
const remoteContents = (remoteFile === null || remoteFile === void 0 ? void 0 : remoteFile.content) || null;
const mode = '100644';
if (localContents !== null) {
if (localContents !== remoteContents) {
Expand All @@ -110,7 +109,6 @@ class Updater {
return {
mode,
path: filePath,
sha: null,
};
}
return null;
Expand All @@ -135,18 +133,17 @@ class Updater {
return null;
}
async getRemoteContents(filePath, branch) {
let content = null;
let sha = null;
try {
const { data } = await this.octokit.repos.getContent(Object.assign(Object.assign({}, github_1.context.repo), { path: filePath, ref: branch }));
content = Buffer.from(data['content'], 'base64').toString();
const content = Buffer.from(data['content'], 'base64').toString();
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
sha = data['sha'];
const sha = data['sha'];
return { content, sha };
}
catch (err) {
// Do nothing
}
return { content, sha };
return null;
}
async updateRef(sha, branch) {
const ref = `heads/${branch}`;
Expand All @@ -166,7 +163,7 @@ exports.Updater = Updater;
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getActionOptions = exports.getPathsToUpdate = exports.getBooleanInput = void 0;
exports.isNotNull = exports.getActionOptions = exports.getPathsToUpdate = exports.getBooleanInput = void 0;
const core_1 = __webpack_require__(186);
function getBooleanInput(name, options) {
const value = core_1.getInput(name, options).toLowerCase();
Expand All @@ -191,6 +188,10 @@ function getActionOptions() {
return { token, message, branch };
}
exports.getActionOptions = getActionOptions;
function isNotNull(arg) {
return arg !== null;
}
exports.isNotNull = isNotNull;


/***/ }),
Expand Down

0 comments on commit dc8f8e2

Please sign in to comment.