reindent
This commit is contained in:
parent
053422e2e1
commit
b836447fac
1 changed files with 27 additions and 28 deletions
55
index.js
55
index.js
|
@ -7,40 +7,39 @@ const getLatestVersion = require("./get-latest-version");
|
||||||
// most @actions toolkit packages have async methods
|
// most @actions toolkit packages have async methods
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
let hugoVersion = core.getInput("hugo-version");
|
getLatestVersion().then(function(latestVersion) {
|
||||||
if (!hugoVersion || hugoVersion === "latest") {
|
let hugoVersion = core.getInput("hugo-version");
|
||||||
hugoVersion = "0.58.2";
|
if (!hugoVersion || hugoVersion === "latest") {
|
||||||
getLatestVersion().then(function(version) {
|
hugoVersion = latestVersion;
|
||||||
console.log(version);
|
}
|
||||||
});
|
core.debug(`Hugo version: ${hugoVersion}`);
|
||||||
}
|
|
||||||
core.debug(`Hugo version: ${hugoVersion}`);
|
|
||||||
|
|
||||||
let extended = core.getInput("extended");
|
let extended = core.getInput("extended");
|
||||||
if (!extended) {
|
if (!extended) {
|
||||||
extended = false;
|
extended = false;
|
||||||
}
|
}
|
||||||
core.debug(`Hugo extended: ${extended}`);
|
core.debug(`Hugo extended: ${extended}`);
|
||||||
|
|
||||||
let extendedStr = "";
|
let extendedStr = "";
|
||||||
if (extended) {
|
if (extended) {
|
||||||
extendedStr = "extended_";
|
extendedStr = "extended_";
|
||||||
}
|
}
|
||||||
|
|
||||||
const hugoName = `hugo_${extendedStr}${hugoVersion}_Linux-64bit`;
|
const hugoName = `hugo_${extendedStr}${hugoVersion}_Linux-64bit`;
|
||||||
core.debug(`hugoName: ${hugoName}`);
|
core.debug(`hugoName: ${hugoName}`);
|
||||||
|
|
||||||
const hugoURL = `https://github.com/gohugoio/hugo/releases/download/v${hugoVersion}/${hugoName}.tar.gz`;
|
const hugoURL = `https://github.com/gohugoio/hugo/releases/download/v${hugoVersion}/${hugoName}.tar.gz`;
|
||||||
core.debug(`hugoURL: ${hugoURL}`);
|
core.debug(`hugoURL: ${hugoURL}`);
|
||||||
|
|
||||||
const hugoPath = "/usr/local/bin";
|
const hugoPath = "/usr/local/bin";
|
||||||
await io.mkdirP(hugoPath);
|
await io.mkdirP(hugoPath);
|
||||||
|
|
||||||
// Download and extract Hugo binary
|
// Download and extract Hugo binary
|
||||||
const hugoTarball = await tc.downloadTool(hugoURL);
|
const hugoTarball = await tc.downloadTool(hugoURL);
|
||||||
const hugoExtractedFolder = await tc.extractTar(hugoTarball, "/tmp");
|
const hugoExtractedFolder = await tc.extractTar(hugoTarball, "/tmp");
|
||||||
core.debug("hugoExtractedFolder:", hugoExtractedFolder);
|
core.debug("hugoExtractedFolder:", hugoExtractedFolder);
|
||||||
await exec.exec("sudo", ["mv", `${hugoExtractedFolder}/hugo`, hugoPath]);
|
await exec.exec("sudo", ["mv", `${hugoExtractedFolder}/hugo`, hugoPath]);
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue