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");
|
|
|
|
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* () {
|
2020-05-15 05:33:08 +08:00
|
|
|
let status = constants_1.Status.RUNNING;
|
2020-03-02 22:38:52 +08:00
|
|
|
try {
|
2020-07-05 03:47:14 +08:00
|
|
|
core_1.info(`
|
|
|
|
GitHub Pages Deploy Action 🚀
|
2020-07-05 03:42:13 +08:00
|
|
|
|
2020-07-14 01:09:22 +08:00
|
|
|
🚀 Getting Started Guide: https://github.com/marketplace/actions/deploy-to-github-pages
|
2020-10-18 03:22:15 +08:00
|
|
|
❓ Discussions / Q&A: https://github.com/JamesIves/github-pages-deploy-action/discussions
|
|
|
|
🔧 Report a Bug: https://github.com/JamesIves/github-pages-deploy-action/issues
|
2020-07-14 01:09:22 +08:00
|
|
|
|
2020-10-18 03:22:15 +08:00
|
|
|
📣 Maintained by James Ives: https://jamesiv.es
|
|
|
|
💖 Support: https://github.com/sponsors/JamesIves`);
|
2020-03-31 20:48:28 +08:00
|
|
|
core_1.info('Checking configuration and starting deployment… 🚦');
|
2020-10-18 03:22:15 +08:00
|
|
|
const settings = Object.assign({}, configuration);
|
|
|
|
// Defines the repository/folder paths and token types.
|
|
|
|
// Also verifies that the action has all of the required parameters.
|
|
|
|
settings.folderPath = util_1.generateFolderPath(settings);
|
|
|
|
util_1.checkParameters(settings);
|
2020-03-02 22:38:52 +08:00
|
|
|
settings.repositoryPath = util_1.generateRepositoryPath(settings);
|
|
|
|
settings.tokenType = util_1.generateTokenType(settings);
|
|
|
|
yield git_1.init(settings);
|
2020-05-15 05:33:08 +08:00
|
|
|
status = yield git_1.deploy(settings);
|
2020-03-02 22:38:52 +08:00
|
|
|
}
|
|
|
|
catch (error) {
|
2020-05-15 05:33:08 +08:00
|
|
|
status = constants_1.Status.FAILED;
|
2020-03-02 22:38:52 +08:00
|
|
|
core_1.setFailed(error.message);
|
|
|
|
}
|
|
|
|
finally {
|
2020-05-15 05:33:08 +08:00
|
|
|
core_1.info(`${status === constants_1.Status.FAILED
|
2020-05-25 00:39:12 +08:00
|
|
|
? 'Deployment failed! ❌'
|
2020-05-15 05:33:08 +08:00
|
|
|
: status === constants_1.Status.SUCCESS
|
2020-05-25 00:39:12 +08:00
|
|
|
? 'Completed deployment successfully! ✅'
|
2020-05-15 05:33:08 +08:00
|
|
|
: 'There is nothing to commit. Exiting early… 📭'}`);
|
|
|
|
core_1.exportVariable('DEPLOYMENT_STATUS', status);
|
2020-03-02 22:38:52 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
exports.default = run;
|