Compare commits

..

6 Commits

Author SHA1 Message Date
Shohei Ueda
34e697e615 docs: Add Back to TOC link 2019-11-22 12:19:08 +09:00
Shohei Ueda
608a9dce06 Update README.md 2019-11-22 12:17:04 +09:00
peaceiris
bcfd41e8b4 docs: update 2019-11-22 12:15:00 +09:00
Shohei Ueda
0a102fbbed docs: Add tips section (Read Hugo version from file) (#89) 2019-11-22 12:12:20 +09:00
Shohei Ueda
ef869fb22f Path join (#92) 2019-11-22 11:14:44 +09:00
peaceiris
1490c6e417 deps: update 2019-11-22 09:38:27 +09:00
5 changed files with 160 additions and 36 deletions

View File

@@ -8,11 +8,11 @@
## GitHub Actions for Hugo extended and Modules ## GitHub Actions for Hugo
- [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. 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.) 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 | ✅️ | ✅️ | ✅️ | | Support | ✅️ | ✅️ | ✅️ |
## Table of Contents
<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
*Table of Contents*
- [Getting started](#getting-started) - [Getting started](#getting-started)
- [⭐️ Create your workflow](#%EF%B8%8F-create-your-workflow) - [⭐️ Create your workflow](#%EF%B8%8F-create-your-workflow)
- [Options](#options) - [Options](#options)
- [⭐️ Use Hugo extended](#%EF%B8%8F-use-hugo-extended) - [⭐️ Use Hugo extended](#%EF%B8%8F-use-hugo-extended)
- [⭐️ Use the latest version of Hugo](#%EF%B8%8F-use-the-latest-version-of-hugo) - [⭐️ 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) - [License](#license)
- [About the author](#about-the-author) - [About the author](#about-the-author)
@@ -70,9 +76,9 @@ jobs:
# submodules: true # submodules: true
- name: Setup Hugo - name: Setup Hugo
uses: peaceiris/actions-hugo@v2.2.2 uses: peaceiris/actions-hugo@v2.2.4
with: with:
hugo-version: '0.58.3' hugo-version: '0.59.1'
# extended: true # extended: true
- name: Build - name: Build
@@ -86,6 +92,10 @@ jobs:
PUBLISH_DIR: ./public PUBLISH_DIR: ./public
``` ```
<div align="right">
<a href="#table-of-contents">Back to TOC ☝️</a>
</div>
## Options ## Options
@@ -96,9 +106,9 @@ Set `extended: true` to use a Hugo extended version.
```yaml ```yaml
- name: Setup Hugo - name: Setup Hugo
uses: peaceiris/actions-hugo@v2.2.2 uses: peaceiris/actions-hugo@v2.2.4
with: with:
hugo-version: '0.58.3' hugo-version: '0.59.1'
extended: true extended: true
``` ```
@@ -108,13 +118,67 @@ Set `hugo-version: 'latest'` to use the latest version of Hugo.
```yaml ```yaml
- name: Setup Hugo - name: Setup Hugo
uses: peaceiris/actions-hugo@v2.2.2 uses: peaceiris/actions-hugo@v2.2.4
with: with:
hugo-version: 'latest' hugo-version: 'latest'
``` ```
This action fetches the latest version of Hugo by [hugo | Homebrew Formulae](https://formulae.brew.sh/formula/hugo) 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 ## License
@@ -128,3 +192,9 @@ This action fetches the latest version of Hugo by [hugo | Homebrew Formulae](htt
## About the author ## About the author
- [peaceiris's homepage](https://peaceiris.com/) - [peaceiris's homepage](https://peaceiris.com/)
<div align="right">
<a href="#table-of-contents">Back to TOC ☝️</a>
</div>

View File

@@ -5153,6 +5153,18 @@ const tc = __importStar(__webpack_require__(533));
const io = __importStar(__webpack_require__(1)); const io = __importStar(__webpack_require__(1));
const get_os_1 = __importDefault(__webpack_require__(443)); const get_os_1 = __importDefault(__webpack_require__(443));
const get_url_1 = __importDefault(__webpack_require__(901)); 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) { function installer(version) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
@@ -5162,17 +5174,25 @@ function installer(version) {
console.log(`Operating System: ${osName}`); console.log(`Operating System: ${osName}`);
const hugoURL = get_url_1.default(osName, extended, version); const hugoURL = get_url_1.default(osName, extended, version);
core.debug(`hugoURL: ${hugoURL}`); 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); yield io.mkdirP(hugoPath);
core.addPath(hugoPath); core.addPath(hugoPath);
yield io.mkdirP(tempDir);
const hugoAssets = yield tc.downloadTool(hugoURL); const hugoAssets = yield tc.downloadTool(hugoURL);
let hugoBin = ''; let hugoBin = '';
if (osName === 'Windows') { if (osName === 'Windows') {
const hugoExtractedFolder = yield tc.extractZip(hugoAssets, '/tmp'); const hugoExtractedFolder = yield tc.extractZip(hugoAssets, tempDir);
hugoBin = `${hugoExtractedFolder}/hugo.exe`; hugoBin = `${hugoExtractedFolder}/hugo.exe`;
} }
else { else {
const hugoExtractedFolder = yield tc.extractTar(hugoAssets, '/tmp'); const hugoExtractedFolder = yield tc.extractTar(hugoAssets, tempDir);
hugoBin = `${hugoExtractedFolder}/hugo`; hugoBin = `${hugoExtractedFolder}/hugo`;
} }
yield io.mv(hugoBin, hugoPath); yield io.mv(hugoBin, hugoPath);

53
package-lock.json generated
View File

@@ -566,9 +566,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "12.12.8", "version": "12.12.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.8.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.11.tgz",
"integrity": "sha512-XLla8N+iyfjvsa0KKV+BP/iGSoTmwxsu5Ci5sM33z9TjohF72DEz95iNvD6pPmemvbQgxAv/909G73gUn8QR7w==", "integrity": "sha512-O+x6uIpa6oMNTkPuHDa9MhMMehlxLAd5QcOvKRjAFsBVpeFWTOPnXbDvILvFgFFZfQ1xh1EZi1FbXxUix+zpsQ==",
"dev": true "dev": true
}, },
"@types/normalize-package-data": { "@types/normalize-package-data": {
@@ -599,36 +599,37 @@
"dev": true "dev": true
}, },
"@typescript-eslint/experimental-utils": { "@typescript-eslint/experimental-utils": {
"version": "2.7.0", "version": "2.8.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.7.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.8.0.tgz",
"integrity": "sha512-9/L/OJh2a5G2ltgBWJpHRfGnt61AgDeH6rsdg59BH0naQseSwR7abwHq3D5/op0KYD/zFT4LS5gGvWcMmegTEg==", "integrity": "sha512-jZ05E4SxCbbXseQGXOKf3ESKcsGxT8Ucpkp1jiVp55MGhOvZB2twmWKf894PAuVQTCgbPbJz9ZbRDqtUWzP8xA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/json-schema": "^7.0.3", "@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" "eslint-scope": "^5.0.0"
} }
}, },
"@typescript-eslint/parser": { "@typescript-eslint/parser": {
"version": "2.7.0", "version": "2.8.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.7.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.8.0.tgz",
"integrity": "sha512-ctC0g0ZvYclxMh/xI+tyqP0EC2fAo6KicN9Wm2EIao+8OppLfxji7KAGJosQHSGBj3TcqUrA96AjgXuKa5ob2g==", "integrity": "sha512-NseXWzhkucq+JM2HgqAAoKEzGQMb5LuTRjFPLQzGIdLthXMNUfuiskbl7QSykvWW6mvzCtYbw1fYWGa2EIaekw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/eslint-visitor-keys": "^1.0.0", "@types/eslint-visitor-keys": "^1.0.0",
"@typescript-eslint/experimental-utils": "2.7.0", "@typescript-eslint/experimental-utils": "2.8.0",
"@typescript-eslint/typescript-estree": "2.7.0", "@typescript-eslint/typescript-estree": "2.8.0",
"eslint-visitor-keys": "^1.1.0" "eslint-visitor-keys": "^1.1.0"
} }
}, },
"@typescript-eslint/typescript-estree": { "@typescript-eslint/typescript-estree": {
"version": "2.7.0", "version": "2.8.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.7.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.8.0.tgz",
"integrity": "sha512-vVCE/DY72N4RiJ/2f10PTyYekX2OLaltuSIBqeHYI44GQ940VCYioInIb8jKMrK9u855OEJdFC+HmWAZTnC+Ag==", "integrity": "sha512-ksvjBDTdbAQ04cR5JyFSDX113k66FxH1tAXmi+dj6hufsl/G0eMc/f1GgLjEVPkYClDbRKv+rnBFuE5EusomUw==",
"dev": true, "dev": true,
"requires": { "requires": {
"debug": "^4.1.1", "debug": "^4.1.1",
"glob": "^7.1.4", "eslint-visitor-keys": "^1.1.0",
"glob": "^7.1.6",
"is-glob": "^4.0.1", "is-glob": "^4.0.1",
"lodash.unescape": "4.0.1", "lodash.unescape": "4.0.1",
"semver": "^6.3.0", "semver": "^6.3.0",
@@ -644,6 +645,20 @@
"ms": "^2.1.1" "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": { "ms": {
"version": "2.1.2", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
@@ -3045,9 +3060,9 @@
} }
}, },
"husky": { "husky": {
"version": "3.0.9", "version": "3.1.0",
"resolved": "https://registry.npmjs.org/husky/-/husky-3.0.9.tgz", "resolved": "https://registry.npmjs.org/husky/-/husky-3.1.0.tgz",
"integrity": "sha512-Yolhupm7le2/MqC1VYLk/cNmYxsSsqKkTyBhzQHhPK1jFnC89mmmNVuGtLNabjDI6Aj8UNIr0KpRNuBkiC4+sg==", "integrity": "sha512-FJkPoHHB+6s4a+jwPqBudBDvYZsoQW5/HBuMSehC8qDiCe50kpcxeqFoDSlow+9I6wg47YxBoT3WxaURlrDIIQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"chalk": "^2.4.2", "chalk": "^2.4.2",

View File

@@ -54,11 +54,11 @@
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^24.0.23", "@types/jest": "^24.0.23",
"@types/node": "^12.12.8", "@types/node": "^12.12.11",
"@typescript-eslint/parser": "^2.7.0", "@typescript-eslint/parser": "^2.8.0",
"@zeit/ncc": "^0.20.5", "@zeit/ncc": "^0.20.5",
"eslint": "^6.6.0", "eslint": "^6.6.0",
"husky": "^3.0.9", "husky": "^3.1.0",
"jest": "^24.9.0", "jest": "^24.9.0",
"jest-circus": "^24.9.0", "jest-circus": "^24.9.0",
"lint-staged": "^9.4.3", "lint-staged": "^9.4.3",

View File

@@ -3,6 +3,18 @@ import * as tc from '@actions/tool-cache';
import * as io from '@actions/io'; import * as io from '@actions/io';
import getOS from './get-os'; import getOS from './get-os';
import getURL from './get-url'; 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) { export default async function installer(version: string) {
try { try {
@@ -15,23 +27,30 @@ export default async function installer(version: string) {
const hugoURL: string = getURL(osName, extended, version); const hugoURL: string = getURL(osName, extended, version);
core.debug(`hugoURL: ${hugoURL}`); 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); await io.mkdirP(hugoPath);
core.addPath(hugoPath); core.addPath(hugoPath);
// Download and extract Hugo binary // Download and extract Hugo binary
await io.mkdirP(tempDir);
const hugoAssets: string = await tc.downloadTool(hugoURL); const hugoAssets: string = await tc.downloadTool(hugoURL);
let hugoBin: string = ''; let hugoBin: string = '';
if (osName === 'Windows') { if (osName === 'Windows') {
const hugoExtractedFolder: string = await tc.extractZip( const hugoExtractedFolder: string = await tc.extractZip(
hugoAssets, hugoAssets,
'/tmp' tempDir
); );
hugoBin = `${hugoExtractedFolder}/hugo.exe`; hugoBin = `${hugoExtractedFolder}/hugo.exe`;
} else { } else {
const hugoExtractedFolder: string = await tc.extractTar( const hugoExtractedFolder: string = await tc.extractTar(
hugoAssets, hugoAssets,
'/tmp' tempDir
); );
hugoBin = `${hugoExtractedFolder}/hugo`; hugoBin = `${hugoExtractedFolder}/hugo`;
} }