mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-01-25 12:22:17 +01:00
Compare commits
9 Commits
v2.0.0-rc1
...
v2.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3bbd6d1917 | ||
|
|
d46d0aa12e | ||
|
|
85171ece4e | ||
|
|
624c2a083b | ||
|
|
7a9975a8b1 | ||
|
|
c635fd9746 | ||
|
|
19661a5c56 | ||
|
|
c4f3b85a0d | ||
|
|
68358aa004 |
20
.github/workflows/test.yml
vendored
20
.github/workflows/test.yml
vendored
@@ -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: [null]
|
# hugo-version: ['latest']
|
||||||
# hugo-version: [null, 'latest', '0.58.2']
|
# extended: [true]
|
||||||
extended: [null]
|
hugo-version: ['latest', '0.58.2']
|
||||||
# extended: [null, true, false]
|
extended: [true, false]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
@@ -40,9 +40,3 @@ 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
|
|
||||||
|
|||||||
18
README.md
18
README.md
@@ -1,7 +1,7 @@
|
|||||||
[](https://github.com/peaceiris/actions-hugo/blob/master/LICENSE)
|
[](https://github.com/peaceiris/actions-hugo/blob/master/LICENSE)
|
||||||
[](https://github.com/peaceiris/actions-hugo/releases/latest)
|
[](https://github.com/peaceiris/actions-hugo/releases/latest)
|
||||||
[](https://github.com/peaceiris/actions-hugo/releases)
|
[](https://github.com/peaceiris/actions-hugo/releases)
|
||||||
[](https://github.com/peaceiris/actions-hugo/actions)
|
[](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,13 +11,17 @@
|
|||||||
|
|
||||||
- [gohugoio/hugo: The world’s fastest framework for building websites.](https://github.com/gohugoio/hugo)
|
- [gohugoio/hugo: The world’s 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 `.github/workflows/gh-pages.yml`
|
### Create your workflow
|
||||||
|
|
||||||
An example workflow with [GitHub Actions for deploying to GitHub Pages with Static Site Generators]
|
An example workflow `.github/workflows/gh-pages.yml` 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
|
||||||
|
|
||||||
@@ -60,7 +64,7 @@ jobs:
|
|||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
### Hugo extended
|
### Use Hugo extended
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup Hugo
|
- name: Setup Hugo
|
||||||
@@ -70,7 +74,7 @@ jobs:
|
|||||||
extended: true
|
extended: true
|
||||||
```
|
```
|
||||||
|
|
||||||
### Latest version of Hugo
|
### Use the latest version of Hugo
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Setup Hugo
|
- name: Setup Hugo
|
||||||
@@ -79,9 +83,7 @@ jobs:
|
|||||||
hugo-version: 'latest'
|
hugo-version: 'latest'
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note**: This action gets a Hugo latest version by GitHub API. Please be aware of [GitHub API Rate limiting]
|
This action fetches the latest version of Hugo by [hugo | Homebrew Formulae](https://formulae.brew.sh/formula/hugo)
|
||||||
|
|
||||||
[GitHub API Rate limiting]: https://developer.github.com/v3/#rate-limiting
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: 'Hugo build action'
|
name: 'Hugo setup 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,3 +13,6 @@ inputs:
|
|||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'index.js'
|
main: 'index.js'
|
||||||
|
branding:
|
||||||
|
icon: 'package'
|
||||||
|
color: 'yellow'
|
||||||
|
|||||||
@@ -1,22 +1,18 @@
|
|||||||
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://api.github.com/repos/gohugoio/hugo/releases/latest";
|
const url = "https://formulae.brew.sh/api/formula/hugo.json";
|
||||||
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 latestURL = result["assets"][0].browser_download_url;
|
const latestVersion = result.versions.stable;
|
||||||
const latestVersion = latestURL.match(/(\d+).(\d+).(\d+)/g)[0];
|
|
||||||
|
|
||||||
resolve(latestVersion);
|
resolve(latestVersion);
|
||||||
// } else {
|
} else if (xhr.readyState === 4 && xhr.status !== 200) {
|
||||||
// reject(`ERROR: got status ${xhr.status}`);
|
reject(`ERROR: got status ${xhr.status} of ${url}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
81
index.js
81
index.js
@@ -1,51 +1,54 @@
|
|||||||
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(async function(latestVersion) {
|
getLatestVersion().then(
|
||||||
let hugoVersion = core.getInput("hugo-version");
|
async function(latestVersion) {
|
||||||
if (!hugoVersion || hugoVersion === "latest") {
|
let hugoVersion = core.getInput("hugo-version");
|
||||||
hugoVersion = latestVersion;
|
if (!hugoVersion || hugoVersion === "latest") {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
68
node_modules/@actions/exec/package.json
generated
vendored
68
node_modules/@actions/exec/package.json
generated
vendored
@@ -1,15 +1,39 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/exec",
|
"_from": "@actions/exec",
|
||||||
"version": "1.0.1",
|
"_id": "@actions/exec@1.0.1",
|
||||||
"description": "Actions exec lib",
|
"_inBundle": false,
|
||||||
"keywords": [
|
"_integrity": "sha512-nvFkxwiicvpzNiCBF4wFBDfnBvi7xp/as7LE1hBxBxKG2L29+gkIPBiLKMVORL+Hg3JNf07AKRfl0V5djoypjQ==",
|
||||||
"github",
|
"_location": "/@actions/exec",
|
||||||
"actions",
|
"_phantomChildren": {},
|
||||||
"exec"
|
"_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"
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/actions/toolkit/tree/master/packages/exec",
|
"_resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.0.1.tgz",
|
||||||
"license": "MIT",
|
"_shasum": "1624b541165697e7008d7c87bc1f69f191263c6c",
|
||||||
"main": "lib/exec.js",
|
"_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",
|
||||||
|
"devDependencies": {
|
||||||
|
"@actions/io": "^1.0.1"
|
||||||
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "lib",
|
"lib": "lib",
|
||||||
"test": "__tests__"
|
"test": "__tests__"
|
||||||
@@ -17,6 +41,16 @@
|
|||||||
"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"
|
||||||
},
|
},
|
||||||
@@ -28,15 +62,5 @@
|
|||||||
"test": "echo \"Error: run tests from root\" && exit 1",
|
"test": "echo \"Error: run tests from root\" && exit 1",
|
||||||
"tsc": "tsc"
|
"tsc": "tsc"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"version": "1.0.1"
|
||||||
"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
6
package-lock.json
generated
@@ -1334,9 +1334,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eslint": {
|
"eslint": {
|
||||||
"version": "6.3.0",
|
"version": "6.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-6.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint/-/eslint-6.4.0.tgz",
|
||||||
"integrity": "sha512-ZvZTKaqDue+N8Y9g0kp6UPZtS4FSY3qARxBs7p4f0H0iof381XHduqVerFWtK8DPtKmemqbqCFENWSQgPR/Gow==",
|
"integrity": "sha512-WTVEzK3lSFoXUovDHEbkJqCVPEPwbhCq4trDktNI6ygs7aO41d4cDT0JFAT5MivzZeVLWlg7vHL+bgrQv/t3vA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@babel/code-frame": "^7.0.0",
|
"@babel/code-frame": "^7.0.0",
|
||||||
|
|||||||
@@ -26,12 +26,13 @@
|
|||||||
"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.3.0",
|
"eslint": "^6.4.0",
|
||||||
"jest": "^24.9.0"
|
"jest": "^24.9.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user