From 6ebfcbd9d0a5d146b1aa75c7506234b92fe1320a Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Mon, 16 Sep 2019 01:32:20 +0900 Subject: [PATCH] add: hugo --- .github/workflows/test.yml | 6 +++--- index.js | 29 +++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 976b94f..4189558 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,6 +31,6 @@ jobs: - name: Dump run: | - ls -la /usr/local - ls -la ${GOPATH} - #hugo version + ls -la /usr/local/bin + echo ${PATH} + hugo version diff --git a/index.js b/index.js index f72f712..6d98a42 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,9 @@ 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'); -let hugoVersion = ''; -let extended = ''; // most @actions toolkit packages have async methods async function run() { @@ -16,17 +17,33 @@ async function run() { // core.setOutput('time', new Date().toTimeString()); - hugoVersion = core.getInput('hugo-version'); + let hugoVersion = core.getInput('hugo-version'); if (!hugoVersion) { hugoVersion = 'latest'; } - console.log('Hugo version:', hugoVersion); + core.debug('Hugo version:', hugoVersion); - extended = core.getInput('extended'); + let extended = core.getInput('extended'); if (!extended) { 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) { core.setFailed(error.message);