Compare commits

..

51 Commits

Author SHA1 Message Date
peaceiris
41299ad96e fix: dump 2019-09-16 08:19:29 +09:00
peaceiris
a54ee42598 remove: PULL_REQUEST_TEMPLATE.md 2019-09-16 08:17:35 +09:00
peaceiris
f5910f8da5 test 2019-09-16 08:11:59 +09:00
peaceiris
184d0ede63 test 2019-09-16 08:05:58 +09:00
peaceiris
4b14375887 remove: reject 2019-09-16 08:04:23 +09:00
peaceiris
9c125996b3 update: dump 2019-09-16 08:01:16 +09:00
peaceiris
0fe9de2e37 gha: change trigger 2019-09-16 07:54:35 +09:00
peaceiris
ebaa91f383 docs: Update README 2019-09-16 07:50:57 +09:00
peaceiris
e34825e78a gha: change trigger branch to master 2019-09-16 06:44:29 +09:00
peaceiris
f789b5fc87 test: hugo 0.58.2 2019-09-16 06:30:16 +09:00
peaceiris
be1e41bed8 fix: lint 2019-09-16 06:23:28 +09:00
peaceiris
846f4fed60 add: about GitHub API Rate limiting 2019-09-16 06:21:47 +09:00
peaceiris
baeba7a8a7 remove: reject 2019-09-16 05:59:37 +09:00
peaceiris
48daa44ee9 add: print process.platform 2019-09-16 05:52:06 +09:00
peaceiris
722aeff149 enhance 2019-09-16 05:42:48 +09:00
peaceiris
f43706a360 lint: ignore index.test.js 2019-09-16 05:42:15 +09:00
peaceiris
1450cb25b1 gha: enhance 2019-09-16 05:35:21 +09:00
peaceiris
cdad2bd631 fix: extended 2019-09-16 05:30:55 +09:00
peaceiris
bb41c318fe change: hugoPath 2019-09-16 05:22:01 +09:00
peaceiris
23e859c6a8 deps: update 2019-09-16 05:02:11 +09:00
peaceiris
50f614060a add: async 2019-09-16 04:53:14 +09:00
peaceiris
b836447fac reindent 2019-09-16 04:49:06 +09:00
peaceiris
053422e2e1 fix: core.debug 2019-09-16 04:39:56 +09:00
peaceiris
8b02a56ca6 deps: install xmlhttprequest 2019-09-16 03:54:38 +09:00
peaceiris
c697c41ad2 fix: getLatestVersion() 2019-09-16 03:43:48 +09:00
peaceiris
457d23d414 add: getLatestVersion() 2019-09-16 03:16:06 +09:00
peaceiris
e07f1d30e8 fix latest 2019-09-16 02:34:54 +09:00
peaceiris
67efaf1f63 fix latest 2019-09-16 02:31:49 +09:00
peaceiris
d44adaf4fe add: sudo mv hugo 2019-09-16 02:11:19 +09:00
peaceiris
9e04da8578 add: core.addPath() 2019-09-16 02:06:57 +09:00
peaceiris
349881b966 add: hugoPath 2019-09-16 02:03:41 +09:00
peaceiris
fddee393fc fix: path to extract 2019-09-16 01:53:34 +09:00
peaceiris
0606233eb3 disable latest 2019-09-16 01:49:48 +09:00
peaceiris
1671d5c394 fix: io.mv 2019-09-16 01:45:15 +09:00
peaceiris
2f1bf01c45 npm install 2019-09-16 01:39:51 +09:00
peaceiris
d565469b6b fix: Test action step 2019-09-16 01:36:15 +09:00
peaceiris
ab39230346 npm install 2019-09-16 01:34:37 +09:00
peaceiris
6ebfcbd9d0 add: hugo 2019-09-16 01:32:20 +09:00
peaceiris
d0f7b9206e add: dump step 2019-09-16 00:55:32 +09:00
peaceiris
88accf1aa5 add: extended false 2019-09-16 00:26:11 +09:00
peaceiris
c2a052ead3 add: hugoVersion latest 2019-09-16 00:22:08 +09:00
peaceiris
03bccf68b8 remove: milliseconds option 2019-09-16 00:04:26 +09:00
peaceiris
45bd07a5c0 fix: workflow syntax 2019-09-15 20:27:05 +09:00
peaceiris
9aa599a7fb fix: workflow syntax 2019-09-15 20:26:16 +09:00
peaceiris
843ac84fed add: options hugo-version and extended 2019-09-15 20:24:31 +09:00
peaceiris
42a06b08e9 prod dependencies 2019-09-15 17:25:51 +09:00
peaceiris
e7a5cc7ef7 chore: 🤖 Update package.json 2019-09-15 17:20:55 +09:00
peaceiris
df70d77351 gha: update test workflow 2019-09-15 17:08:08 +09:00
peaceiris
8ffc478ba7 feat: Add JavaScript action template
https://github.com/actions/javascript-action
2019-09-15 16:52:29 +09:00
peaceiris
2905a7fc5b feat: Remove Docker action 2019-09-15 16:48:15 +09:00
peaceiris
fee1e1cc48 gha: remove docker ci workflow 2019-09-15 05:29:56 +09:00
8 changed files with 96 additions and 119 deletions

View File

@@ -18,19 +18,19 @@ jobs:
# - name: Test script # - name: Test script
# run: npm test # run: npm test
# - name: Build production - name: Build production
# run: npm run build run: npm run build
test-prod: test-prod:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
needs: test
strategy: strategy:
matrix: matrix:
# hugo-version: ['latest'] hugo-version: [null]
# extended: [true] # hugo-version: [null, 'latest', '0.58.2']
hugo-version: ['latest', '0.58.2'] extended: [null]
extended: [true, false] # extended: [null, true, false]
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
@@ -40,3 +40,9 @@ jobs:
with: with:
hugo-version: ${{ matrix.hugo-version }} hugo-version: ${{ matrix.hugo-version }}
extended: ${{ matrix.extended }} extended: ${{ matrix.extended }}
- name: Dump
run: |
hugo version
go version
git --version

View File

@@ -1,7 +1,7 @@
[![license](https://img.shields.io/github/license/peaceiris/actions-hugo.svg)](https://github.com/peaceiris/actions-hugo/blob/master/LICENSE) [![license](https://img.shields.io/github/license/peaceiris/actions-hugo.svg)](https://github.com/peaceiris/actions-hugo/blob/master/LICENSE)
[![release](https://img.shields.io/github/release/peaceiris/actions-hugo.svg)](https://github.com/peaceiris/actions-hugo/releases/latest) [![release](https://img.shields.io/github/release/peaceiris/actions-hugo.svg)](https://github.com/peaceiris/actions-hugo/releases/latest)
[![GitHub release date](https://img.shields.io/github/release-date/peaceiris/actions-hugo.svg)](https://github.com/peaceiris/actions-hugo/releases) [![GitHub release date](https://img.shields.io/github/release-date/peaceiris/actions-hugo.svg)](https://github.com/peaceiris/actions-hugo/releases)
[![GitHub Actions status](https://github.com/peaceiris/actions-hugo/workflows/Test/badge.svg)](https://github.com/peaceiris/actions-hugo/actions) [![GitHub Actions status](https://github.com/peaceiris/actions-hugo/workflows/.github/workflows/test.yml/badge.svg)](https://github.com/peaceiris/actions-hugo/actions)
<img width="400" alt="GitHub Actions for Hugo" src="./images/ogp.svg"> <img width="400" alt="GitHub Actions for Hugo" src="./images/ogp.svg">
@@ -11,17 +11,13 @@
- [gohugoio/hugo: The worlds fastest framework for building websites.](https://github.com/gohugoio/hugo) - [gohugoio/hugo: The worlds fastest framework for building websites.](https://github.com/gohugoio/hugo)
We can run Hugo on a virtual machine of GitHub Actions by this Hugo action. Hugo extended version and Hugo Modules are supported.
From `v2.0.0`, this Hugo action migrated to a JavaScript action. We no longer build or pull a Hugo docker image. Thanks to this change, we can complete this action less than **2 sec**. (A docker base action was taking about 1 min or more execution time to build or pull.)
## Getting started ## Getting started
### Create your workflow ### Create `.github/workflows/gh-pages.yml`
An example workflow `.github/workflows/gh-pages.yml` with [GitHub Actions for deploying to GitHub Pages with Static Site Generators] An example workflow with [GitHub Actions for deploying to GitHub Pages with Static Site Generators]
[GitHub Actions for deploying to GitHub Pages with Static Site Generators]: https://github.com/peaceiris/actions-gh-pages [GitHub Actions for deploying to GitHub Pages with Static Site Generators]: https://github.com/peaceiris/actions-gh-pages
@@ -64,7 +60,7 @@ jobs:
## Options ## Options
### Use Hugo extended ### Hugo extended
```yaml ```yaml
- name: Setup Hugo - name: Setup Hugo
@@ -74,7 +70,7 @@ jobs:
extended: true extended: true
``` ```
### Use the latest version of Hugo ### Latest version of Hugo
```yaml ```yaml
- name: Setup Hugo - name: Setup Hugo
@@ -83,7 +79,9 @@ jobs:
hugo-version: 'latest' hugo-version: 'latest'
``` ```
This action fetches the latest version of Hugo by [hugo | Homebrew Formulae](https://formulae.brew.sh/formula/hugo) **Note**: This action gets a Hugo latest version by GitHub API. Please be aware of [GitHub API Rate limiting]
[GitHub API Rate limiting]: https://developer.github.com/v3/#rate-limiting

View File

@@ -1,4 +1,4 @@
name: 'Hugo setup action' name: 'Hugo build action'
description: 'GitHub Actions for Hugo extended and Hugo Modules' description: 'GitHub Actions for Hugo extended and Hugo Modules'
author: 'peaceiris' author: 'peaceiris'
inputs: inputs:
@@ -13,6 +13,3 @@ inputs:
runs: runs:
using: 'node12' using: 'node12'
main: 'index.js' main: 'index.js'
branding:
icon: 'package'
color: 'yellow'

View File

@@ -1,18 +1,22 @@
const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest; const XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
function getLatestVersion() { function getLatestVersion() {
return new Promise((resolve, reject) => { // return new Promise((resolve, reject) => {
return new Promise(resolve => {
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
const url = "https://formulae.brew.sh/api/formula/hugo.json"; const url = "https://api.github.com/repos/gohugoio/hugo/releases/latest";
xhr.open("GET", url); xhr.open("GET", url);
xhr.send(); xhr.send();
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) { if (xhr.readyState === 4 && xhr.status === 200) {
const result = JSON.parse(xhr.responseText); const result = JSON.parse(xhr.responseText);
const latestVersion = result.versions.stable; const latestURL = result["assets"][0].browser_download_url;
const latestVersion = latestURL.match(/(\d+).(\d+).(\d+)/g)[0];
resolve(latestVersion); resolve(latestVersion);
} else if (xhr.readyState === 4 && xhr.status !== 200) { // } else {
reject(`ERROR: got status ${xhr.status} of ${url}`); // reject(`ERROR: got status ${xhr.status}`);
} }
}; };
}); });

View File

@@ -1,54 +1,51 @@
const core = require("@actions/core"); const core = require("@actions/core");
const tc = require("@actions/tool-cache"); const tc = require("@actions/tool-cache");
const io = require("@actions/io"); const io = require("@actions/io");
const exec = require("@actions/exec");
const getLatestVersion = require("./get-latest-version"); 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 {
getLatestVersion().then( getLatestVersion().then(async function(latestVersion) {
async function(latestVersion) { let hugoVersion = core.getInput("hugo-version");
let hugoVersion = core.getInput("hugo-version"); if (!hugoVersion || hugoVersion === "latest") {
if (!hugoVersion || hugoVersion === "latest") { hugoVersion = latestVersion;
hugoVersion = latestVersion;
}
console.log(`Hugo version: ${hugoVersion}`);
const extended = core.getInput("extended");
console.log(`Hugo extended: ${extended}`);
let extendedStr = "";
if (extended === "true") {
extendedStr = "extended_";
}
console.log(`Operating System: ${process.platform}`);
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 hugoPath = `${process.env.HOME}/bin`;
await io.mkdirP(hugoPath);
core.addPath(hugoPath);
// Download and extract Hugo binary
const hugoTarball = await tc.downloadTool(hugoURL);
const hugoExtractedFolder = await tc.extractTar(hugoTarball, "/tmp");
core.debug("hugoExtractedFolder:", hugoExtractedFolder);
await io.mv(`${hugoExtractedFolder}/hugo`, hugoPath);
// Show version
await exec.exec('hugo version');
await exec.exec('go version');
await exec.exec('git --version');
},
function(error) {
core.setFailed(error);
} }
); core.debug(`Hugo version: ${hugoVersion}`);
let extended = core.getInput("extended");
core.debug(`Hugo extended: ${extended}`);
let extendedStr = "";
if (extended === "true") {
extendedStr = "extended_";
}
console.log(`Operating System: ${process.platform}`);
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 hugoPath = "/home/runner/bin";
await io.mkdirP(hugoPath);
core.addPath(hugoPath);
// Download and extract Hugo binary
const hugoTarball = await tc.downloadTool(hugoURL);
const hugoExtractedFolder = await tc.extractTar(hugoTarball, "/tmp");
core.debug("hugoExtractedFolder:", hugoExtractedFolder);
await io.mv(`${hugoExtractedFolder}/hugo`, hugoPath);
// },
// function(error) {
// console.error(error);
// console.log(
// "HINT: GitHub API Rate limiting",
// "https://developer.github.com/v3/#rate-limiting"
// );
});
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);
} }

View File

@@ -1,39 +1,15 @@
{ {
"_from": "@actions/exec", "name": "@actions/exec",
"_id": "@actions/exec@1.0.1", "version": "1.0.1",
"_inBundle": false,
"_integrity": "sha512-nvFkxwiicvpzNiCBF4wFBDfnBvi7xp/as7LE1hBxBxKG2L29+gkIPBiLKMVORL+Hg3JNf07AKRfl0V5djoypjQ==",
"_location": "/@actions/exec",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "@actions/exec",
"name": "@actions/exec",
"escapedName": "@actions%2fexec",
"scope": "@actions",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/",
"/@actions/tool-cache"
],
"_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.1.tgz",
"_shasum": "1624b541165697e7008d7c87bc1f69f191263c6c",
"_spec": "@actions/exec",
"_where": "/Users/iris/Documents/repos/github.com/peaceiris/actions-hugo",
"bugs": {
"url": "https://github.com/actions/toolkit/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Actions exec lib", "description": "Actions exec lib",
"devDependencies": { "keywords": [
"@actions/io": "^1.0.1" "github",
}, "actions",
"exec"
],
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
"license": "MIT",
"main": "lib/exec.js",
"directories": { "directories": {
"lib": "lib", "lib": "lib",
"test": "__tests__" "test": "__tests__"
@@ -41,16 +17,6 @@
"files": [ "files": [
"lib" "lib"
], ],
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52",
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
"keywords": [
"github",
"actions",
"exec"
],
"license": "MIT",
"main": "lib/exec.js",
"name": "@actions/exec",
"publishConfig": { "publishConfig": {
"access": "public" "access": "public"
}, },
@@ -62,5 +28,15 @@
"test": "echo \"Error: run tests from root\" && exit 1", "test": "echo \"Error: run tests from root\" && exit 1",
"tsc": "tsc" "tsc": "tsc"
}, },
"version": "1.0.1" "bugs": {
} "url": "https://github.com/actions/toolkit/issues"
},
"devDependencies": {
"@actions/io": "^1.0.1"
},
"gitHead": "a2ab4bcf78e4f7080f0d45856e6eeba16f0bbc52"
,"_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.1.tgz"
,"_integrity": "sha512-nvFkxwiicvpzNiCBF4wFBDfnBvi7xp/as7LE1hBxBxKG2L29+gkIPBiLKMVORL+Hg3JNf07AKRfl0V5djoypjQ=="
,"_from": "@actions/exec@1.0.1"
}

6
package-lock.json generated
View File

@@ -1334,9 +1334,9 @@
} }
}, },
"eslint": { "eslint": {
"version": "6.4.0", "version": "6.3.0",
"resolved": "https://registry.npmjs.org/eslint/-/eslint-6.4.0.tgz", "resolved": "https://registry.npmjs.org/eslint/-/eslint-6.3.0.tgz",
"integrity": "sha512-WTVEzK3lSFoXUovDHEbkJqCVPEPwbhCq4trDktNI6ygs7aO41d4cDT0JFAT5MivzZeVLWlg7vHL+bgrQv/t3vA==", "integrity": "sha512-ZvZTKaqDue+N8Y9g0kp6UPZtS4FSY3qARxBs7p4f0H0iof381XHduqVerFWtK8DPtKmemqbqCFENWSQgPR/Gow==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/code-frame": "^7.0.0", "@babel/code-frame": "^7.0.0",

View File

@@ -26,13 +26,12 @@
"homepage": "https://github.com/peaceiris/actions-hugo#readme", "homepage": "https://github.com/peaceiris/actions-hugo#readme",
"dependencies": { "dependencies": {
"@actions/core": "^1.1.0", "@actions/core": "^1.1.0",
"@actions/exec": "^1.0.1",
"@actions/io": "^1.0.1", "@actions/io": "^1.0.1",
"@actions/tool-cache": "^1.1.1", "@actions/tool-cache": "^1.1.1",
"xmlhttprequest": "^1.8.0" "xmlhttprequest": "^1.8.0"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^6.4.0", "eslint": "^6.3.0",
"jest": "^24.9.0" "jest": "^24.9.0"
} }
} }