add: hugo

This commit is contained in:
peaceiris 2019-09-16 01:32:20 +09:00
parent d0f7b9206e
commit 6ebfcbd9d0
2 changed files with 26 additions and 9 deletions

View file

@ -31,6 +31,6 @@ jobs:
- name: Dump - name: Dump
run: | run: |
ls -la /usr/local ls -la /usr/local/bin
ls -la ${GOPATH} echo ${PATH}
#hugo version hugo version

View file

@ -1,8 +1,9 @@
const core = require('@actions/core'); const core = require('@actions/core');
const exec = require('@actions/exec');
const tc = require('@actions/tool-cache');
const io = require('@actions/io');
// const wait = require('./wait'); // const wait = require('./wait');
let hugoVersion = '';
let extended = '';
// most @actions toolkit packages have async methods // most @actions toolkit packages have async methods
async function run() { async function run() {
@ -16,17 +17,33 @@ async function run() {
// core.setOutput('time', new Date().toTimeString()); // core.setOutput('time', new Date().toTimeString());
hugoVersion = core.getInput('hugo-version'); let hugoVersion = core.getInput('hugo-version');
if (!hugoVersion) { if (!hugoVersion) {
hugoVersion = 'latest'; hugoVersion = 'latest';
} }
console.log('Hugo version:', hugoVersion); core.debug('Hugo version:', hugoVersion);
extended = core.getInput('extended'); let extended = core.getInput('extended');
if (!extended) { if (!extended) {
extended = false; extended = false;
} }
console.log('Hugo extended:', extended); core.debug('Hugo extended:', extended);
let extendedStr = '';
if (extended) {
extendedStr = 'extended_';
}
const hugoName = `hugo_${extendedStr}${hugoVersion}_Linux-64bit`;
core.debug('hugoName:', hugoName);
const hugoURL = `https://github.com/gohugoio/hugo/releases/download/v${hugoVersion}/${hugoName}.tar.gz`;
core.debug('hugoURL:', hugoURL);
const hugoTarball = await tc.downloadTool(hugoURL);
const hugoExtractedFolder = await tc.extractTar(hugoTarball, '/tmp/hugo');
core.debug('hugoExtractedFolder:', hugoExtractedFolder);
await io.mv('/tmp/hugo/hugo', '/usr/local/bin/');
} }
catch (error) { catch (error) {
core.setFailed(error.message); core.setFailed(error.message);