github-pages-deploy-action/lib/lib.js

47 lines
2.0 KiB
JavaScript
Raw Normal View History

2020-03-02 22:38:52 +08:00
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@actions/core");
const constants_1 = require("./constants");
const git_1 = require("./git");
exports.deploy = git_1.deploy;
exports.generateBranch = git_1.generateBranch;
exports.init = git_1.init;
const util_1 = require("./util");
2020-03-31 20:48:28 +08:00
/** Initializes and runs the action.
*
* @param {object} configuration - The action configuration.
*/
2020-03-02 22:38:52 +08:00
function run(configuration) {
return __awaiter(this, void 0, void 0, function* () {
let errorState = false;
try {
2020-03-31 20:48:28 +08:00
core_1.info('Checking configuration and starting deployment… 🚦');
2020-03-02 22:38:52 +08:00
const settings = Object.assign(Object.assign({}, constants_1.action), configuration);
// Defines the repository paths and token types.
settings.repositoryPath = util_1.generateRepositoryPath(settings);
settings.tokenType = util_1.generateTokenType(settings);
yield git_1.init(settings);
yield git_1.deploy(settings);
}
catch (error) {
errorState = true;
core_1.setFailed(error.message);
}
finally {
2020-03-31 20:48:28 +08:00
core_1.info(`${errorState
2020-03-07 11:45:40 +08:00
? 'Deployment Failed ❌'
: 'Completed Deployment Successfully! ✅'}`);
2020-03-02 22:38:52 +08:00
}
});
}
exports.default = run;