mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-01-25 12:22:17 +01:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34e697e615 | ||
|
|
608a9dce06 | ||
|
|
bcfd41e8b4 | ||
|
|
0a102fbbed | ||
|
|
ef869fb22f | ||
|
|
1490c6e417 |
86
README.md
86
README.md
@@ -8,11 +8,11 @@
|
||||
|
||||
|
||||
|
||||
## GitHub Actions for Hugo extended and Modules
|
||||
## GitHub Actions for 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.
|
||||
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 (TypeScript) action. We no longer build or pull a Hugo docker image. Thanks to this change, we can complete this action less than **4 sec**. (A docker base action was taking about 1 min or more execution time to build or pull.)
|
||||
|
||||
@@ -24,15 +24,21 @@ From `v2.0.0`, this Hugo action migrated to a JavaScript (TypeScript) action. W
|
||||
|---|:---:|:---:|:---:|
|
||||
| Support | ✅️ | ✅️ | ✅️ |
|
||||
|
||||
|
||||
|
||||
## Table of Contents
|
||||
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
*Table of Contents*
|
||||
|
||||
|
||||
- [Getting started](#getting-started)
|
||||
- [⭐️ Create your workflow](#%EF%B8%8F-create-your-workflow)
|
||||
- [Options](#options)
|
||||
- [⭐️ Use Hugo extended](#%EF%B8%8F-use-hugo-extended)
|
||||
- [⭐️ Use the latest version of Hugo](#%EF%B8%8F-use-the-latest-version-of-hugo)
|
||||
- [Tips](#tips)
|
||||
- [⭐️ Read Hugo version from file](#%EF%B8%8F-read-hugo-version-from-file)
|
||||
- [License](#license)
|
||||
- [About the author](#about-the-author)
|
||||
|
||||
@@ -70,9 +76,9 @@ jobs:
|
||||
# submodules: true
|
||||
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2.2.2
|
||||
uses: peaceiris/actions-hugo@v2.2.4
|
||||
with:
|
||||
hugo-version: '0.58.3'
|
||||
hugo-version: '0.59.1'
|
||||
# extended: true
|
||||
|
||||
- name: Build
|
||||
@@ -86,6 +92,10 @@ jobs:
|
||||
PUBLISH_DIR: ./public
|
||||
```
|
||||
|
||||
<div align="right">
|
||||
<a href="#table-of-contents">Back to TOC ☝️</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
## Options
|
||||
@@ -96,9 +106,9 @@ Set `extended: true` to use a Hugo extended version.
|
||||
|
||||
```yaml
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2.2.2
|
||||
uses: peaceiris/actions-hugo@v2.2.4
|
||||
with:
|
||||
hugo-version: '0.58.3'
|
||||
hugo-version: '0.59.1'
|
||||
extended: true
|
||||
```
|
||||
|
||||
@@ -108,13 +118,67 @@ Set `hugo-version: 'latest'` to use the latest version of Hugo.
|
||||
|
||||
```yaml
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2.2.2
|
||||
uses: peaceiris/actions-hugo@v2.2.4
|
||||
with:
|
||||
hugo-version: 'latest'
|
||||
```
|
||||
|
||||
This action fetches the latest version of Hugo by [hugo | Homebrew Formulae](https://formulae.brew.sh/formula/hugo)
|
||||
|
||||
<div align="right">
|
||||
<a href="#table-of-contents">Back to TOC ☝️</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
## Tips
|
||||
|
||||
### ⭐️ Read Hugo version from file
|
||||
|
||||
How to sync a Hugo version between Docker Compose YAML file and a GitHub Actions workflow using `.env` file.
|
||||
|
||||
Write a `HUGO_VERSION` to the `.env` file like the following and push it to a remote branch.
|
||||
|
||||
```sh
|
||||
HUGO_VERSION=0.59.1
|
||||
```
|
||||
|
||||
Next, add a step to read a Hugo version from the `.env` file.
|
||||
|
||||
```yaml
|
||||
- name: Read .env
|
||||
id: hugo-version
|
||||
run: |
|
||||
. ./.env
|
||||
echo "::set-output name=HUGO_VERSION::${HUGO_VERSION}"
|
||||
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2.2.4
|
||||
with:
|
||||
hugo-version: '${{ steps.hugo-version.outputs.HUGO_VERSION }}'
|
||||
extended: true
|
||||
```
|
||||
|
||||
Here is a `docker-compose.yml` example.
|
||||
|
||||
```yaml
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
hugo:
|
||||
container_name: hugo
|
||||
image: "peaceiris/hugo:v${HUGO_VERSION}"
|
||||
# image: peaceiris/hugo:v${HUGO_VERSION}-mod # Hugo Modules
|
||||
ports:
|
||||
- 1313:1313
|
||||
volumes:
|
||||
- ${PWD}:/src
|
||||
command:
|
||||
- server
|
||||
- --bind=0.0.0.0
|
||||
- --buildDrafts
|
||||
```
|
||||
|
||||
|
||||
|
||||
## License
|
||||
@@ -128,3 +192,9 @@ This action fetches the latest version of Hugo by [hugo | Homebrew Formulae](htt
|
||||
## About the author
|
||||
|
||||
- [peaceiris's homepage](https://peaceiris.com/)
|
||||
|
||||
|
||||
|
||||
<div align="right">
|
||||
<a href="#table-of-contents">Back to TOC ☝️</a>
|
||||
</div>
|
||||
|
||||
26
lib/index.js
26
lib/index.js
@@ -5153,6 +5153,18 @@ const tc = __importStar(__webpack_require__(533));
|
||||
const io = __importStar(__webpack_require__(1));
|
||||
const get_os_1 = __importDefault(__webpack_require__(443));
|
||||
const get_url_1 = __importDefault(__webpack_require__(901));
|
||||
const path = __importStar(__webpack_require__(622));
|
||||
let tempDir = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
||||
if (!tempDir) {
|
||||
let baseTempLocation;
|
||||
if (process.platform === 'win32') {
|
||||
baseTempLocation = process.env['USERPROFILE'] || 'C:\\';
|
||||
}
|
||||
else {
|
||||
baseTempLocation = `${process.env.HOME}`;
|
||||
}
|
||||
tempDir = path.join(baseTempLocation, 'tmp');
|
||||
}
|
||||
function installer(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
@@ -5162,17 +5174,25 @@ function installer(version) {
|
||||
console.log(`Operating System: ${osName}`);
|
||||
const hugoURL = get_url_1.default(osName, extended, version);
|
||||
core.debug(`hugoURL: ${hugoURL}`);
|
||||
const hugoPath = `${process.env.HOME}/bin`;
|
||||
let baseLocation;
|
||||
if (process.platform === 'win32') {
|
||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
||||
}
|
||||
else {
|
||||
baseLocation = `${process.env.HOME}`;
|
||||
}
|
||||
const hugoPath = path.join(baseLocation, 'hugobin');
|
||||
yield io.mkdirP(hugoPath);
|
||||
core.addPath(hugoPath);
|
||||
yield io.mkdirP(tempDir);
|
||||
const hugoAssets = yield tc.downloadTool(hugoURL);
|
||||
let hugoBin = '';
|
||||
if (osName === 'Windows') {
|
||||
const hugoExtractedFolder = yield tc.extractZip(hugoAssets, '/tmp');
|
||||
const hugoExtractedFolder = yield tc.extractZip(hugoAssets, tempDir);
|
||||
hugoBin = `${hugoExtractedFolder}/hugo.exe`;
|
||||
}
|
||||
else {
|
||||
const hugoExtractedFolder = yield tc.extractTar(hugoAssets, '/tmp');
|
||||
const hugoExtractedFolder = yield tc.extractTar(hugoAssets, tempDir);
|
||||
hugoBin = `${hugoExtractedFolder}/hugo`;
|
||||
}
|
||||
yield io.mv(hugoBin, hugoPath);
|
||||
|
||||
53
package-lock.json
generated
53
package-lock.json
generated
@@ -566,9 +566,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "12.12.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.8.tgz",
|
||||
"integrity": "sha512-XLla8N+iyfjvsa0KKV+BP/iGSoTmwxsu5Ci5sM33z9TjohF72DEz95iNvD6pPmemvbQgxAv/909G73gUn8QR7w==",
|
||||
"version": "12.12.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.11.tgz",
|
||||
"integrity": "sha512-O+x6uIpa6oMNTkPuHDa9MhMMehlxLAd5QcOvKRjAFsBVpeFWTOPnXbDvILvFgFFZfQ1xh1EZi1FbXxUix+zpsQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/normalize-package-data": {
|
||||
@@ -599,36 +599,37 @@
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/experimental-utils": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.7.0.tgz",
|
||||
"integrity": "sha512-9/L/OJh2a5G2ltgBWJpHRfGnt61AgDeH6rsdg59BH0naQseSwR7abwHq3D5/op0KYD/zFT4LS5gGvWcMmegTEg==",
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.8.0.tgz",
|
||||
"integrity": "sha512-jZ05E4SxCbbXseQGXOKf3ESKcsGxT8Ucpkp1jiVp55MGhOvZB2twmWKf894PAuVQTCgbPbJz9ZbRDqtUWzP8xA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/json-schema": "^7.0.3",
|
||||
"@typescript-eslint/typescript-estree": "2.7.0",
|
||||
"@typescript-eslint/typescript-estree": "2.8.0",
|
||||
"eslint-scope": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/parser": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.7.0.tgz",
|
||||
"integrity": "sha512-ctC0g0ZvYclxMh/xI+tyqP0EC2fAo6KicN9Wm2EIao+8OppLfxji7KAGJosQHSGBj3TcqUrA96AjgXuKa5ob2g==",
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.8.0.tgz",
|
||||
"integrity": "sha512-NseXWzhkucq+JM2HgqAAoKEzGQMb5LuTRjFPLQzGIdLthXMNUfuiskbl7QSykvWW6mvzCtYbw1fYWGa2EIaekw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/eslint-visitor-keys": "^1.0.0",
|
||||
"@typescript-eslint/experimental-utils": "2.7.0",
|
||||
"@typescript-eslint/typescript-estree": "2.7.0",
|
||||
"@typescript-eslint/experimental-utils": "2.8.0",
|
||||
"@typescript-eslint/typescript-estree": "2.8.0",
|
||||
"eslint-visitor-keys": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/typescript-estree": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.7.0.tgz",
|
||||
"integrity": "sha512-vVCE/DY72N4RiJ/2f10PTyYekX2OLaltuSIBqeHYI44GQ940VCYioInIb8jKMrK9u855OEJdFC+HmWAZTnC+Ag==",
|
||||
"version": "2.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.8.0.tgz",
|
||||
"integrity": "sha512-ksvjBDTdbAQ04cR5JyFSDX113k66FxH1tAXmi+dj6hufsl/G0eMc/f1GgLjEVPkYClDbRKv+rnBFuE5EusomUw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "^4.1.1",
|
||||
"glob": "^7.1.4",
|
||||
"eslint-visitor-keys": "^1.1.0",
|
||||
"glob": "^7.1.6",
|
||||
"is-glob": "^4.0.1",
|
||||
"lodash.unescape": "4.0.1",
|
||||
"semver": "^6.3.0",
|
||||
@@ -644,6 +645,20 @@
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.6",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz",
|
||||
"integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
@@ -3045,9 +3060,9 @@
|
||||
}
|
||||
},
|
||||
"husky": {
|
||||
"version": "3.0.9",
|
||||
"resolved": "https://registry.npmjs.org/husky/-/husky-3.0.9.tgz",
|
||||
"integrity": "sha512-Yolhupm7le2/MqC1VYLk/cNmYxsSsqKkTyBhzQHhPK1jFnC89mmmNVuGtLNabjDI6Aj8UNIr0KpRNuBkiC4+sg==",
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/husky/-/husky-3.1.0.tgz",
|
||||
"integrity": "sha512-FJkPoHHB+6s4a+jwPqBudBDvYZsoQW5/HBuMSehC8qDiCe50kpcxeqFoDSlow+9I6wg47YxBoT3WxaURlrDIIQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^2.4.2",
|
||||
|
||||
@@ -54,11 +54,11 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^24.0.23",
|
||||
"@types/node": "^12.12.8",
|
||||
"@typescript-eslint/parser": "^2.7.0",
|
||||
"@types/node": "^12.12.11",
|
||||
"@typescript-eslint/parser": "^2.8.0",
|
||||
"@zeit/ncc": "^0.20.5",
|
||||
"eslint": "^6.6.0",
|
||||
"husky": "^3.0.9",
|
||||
"husky": "^3.1.0",
|
||||
"jest": "^24.9.0",
|
||||
"jest-circus": "^24.9.0",
|
||||
"lint-staged": "^9.4.3",
|
||||
|
||||
@@ -3,6 +3,18 @@ import * as tc from '@actions/tool-cache';
|
||||
import * as io from '@actions/io';
|
||||
import getOS from './get-os';
|
||||
import getURL from './get-url';
|
||||
import * as path from 'path';
|
||||
|
||||
let tempDir: string = process.env['RUNNER_TEMPDIRECTORY'] || '';
|
||||
if (!tempDir) {
|
||||
let baseTempLocation: string;
|
||||
if (process.platform === 'win32') {
|
||||
baseTempLocation = process.env['USERPROFILE'] || 'C:\\';
|
||||
} else {
|
||||
baseTempLocation = `${process.env.HOME}`;
|
||||
}
|
||||
tempDir = path.join(baseTempLocation, 'tmp');
|
||||
}
|
||||
|
||||
export default async function installer(version: string) {
|
||||
try {
|
||||
@@ -15,23 +27,30 @@ export default async function installer(version: string) {
|
||||
const hugoURL: string = getURL(osName, extended, version);
|
||||
core.debug(`hugoURL: ${hugoURL}`);
|
||||
|
||||
const hugoPath: string = `${process.env.HOME}/bin`;
|
||||
let baseLocation: string;
|
||||
if (process.platform === 'win32') {
|
||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
||||
} else {
|
||||
baseLocation = `${process.env.HOME}`;
|
||||
}
|
||||
const hugoPath: string = path.join(baseLocation, 'hugobin');
|
||||
await io.mkdirP(hugoPath);
|
||||
core.addPath(hugoPath);
|
||||
|
||||
// Download and extract Hugo binary
|
||||
await io.mkdirP(tempDir);
|
||||
const hugoAssets: string = await tc.downloadTool(hugoURL);
|
||||
let hugoBin: string = '';
|
||||
if (osName === 'Windows') {
|
||||
const hugoExtractedFolder: string = await tc.extractZip(
|
||||
hugoAssets,
|
||||
'/tmp'
|
||||
tempDir
|
||||
);
|
||||
hugoBin = `${hugoExtractedFolder}/hugo.exe`;
|
||||
} else {
|
||||
const hugoExtractedFolder: string = await tc.extractTar(
|
||||
hugoAssets,
|
||||
'/tmp'
|
||||
tempDir
|
||||
);
|
||||
hugoBin = `${hugoExtractedFolder}/hugo`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user