Compare commits

..

117 Commits

Author SHA1 Message Date
peaceiris
ab3f21340f deps: update 2019-11-17 20:48:26 +09:00
Shohei Ueda
3ab6d78f1e deps: Compile deps into single file with ncc (#88)
* deps: Compile deps into single file with ncc
* ci: update husky setting

Close #67
2019-11-17 20:39:17 +09:00
peaceiris
007cfe211d gha: Remove matrix exclude 2019-11-17 20:07:23 +09:00
peaceiris
1d2fa2a9c3 gha: Add matrix exclude 2019-11-17 20:05:12 +09:00
Shohei Ueda
10b88ee9bf gha: Add cache step (#87) 2019-11-17 19:59:01 +09:00
Shohei Ueda
b93236ba6f deps: upgrade node to 12.13.0 (#86) 2019-11-13 17:29:31 +09:00
Shohei Ueda
535d0e0aa9 gha: update (#85) 2019-11-13 17:05:13 +09:00
peaceiris
90fbf33ad8 deps: update 2019-11-13 16:55:59 +09:00
Shohei Ueda
d3401a30a3 docs: Add codefactor badge 2019-11-13 12:58:32 +09:00
Shohei Ueda
eb85852ce3 deps: update (#83) 2019-11-11 22:17:46 +09:00
Shohei Ueda
3c10f8d88a Update README.md 2019-11-07 08:21:32 +09:00
Shohei Ueda
0de12a826f gha: update to macos-latest 2019-11-07 08:17:43 +09:00
Shohei Ueda
5bb02a4a7d docs: update to macos-latest 2019-11-07 08:15:55 +09:00
peaceiris
9aa9bf7c5a gha: Add paths-ignore to pull_request 2019-11-03 13:57:52 +09:00
Shohei Ueda
3be578e3c5 Update test.yml 2019-11-03 13:29:31 +09:00
peaceiris
ec916d70ad github: Update action meta 2019-10-29 10:03:36 +09:00
peaceiris
d88559854c github: Update action meta 2019-10-29 09:59:34 +09:00
peaceiris
2965e59bb8 deps: update 2019-10-29 09:56:12 +09:00
peaceiris
f0004ebb52 github: Update action meta 2019-10-29 09:54:47 +09:00
peaceiris
0101f0a550 github: Remove FUNDING.yml 2019-10-29 03:26:27 +09:00
Shohei Ueda
c31a671975 Update issue templates 2019-10-29 03:23:41 +09:00
peaceiris
78c603eb60 github: Add issue template config
https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository#configuring-the-template-chooser
2019-10-29 03:17:06 +09:00
Shohei Ueda
bbc02a7bb6 Update issue templates 2019-10-29 03:11:09 +09:00
peaceiris
8e53828e04 docs: Remove Hugo --gc flag
This flag should be used on local.
It is wasteful to use the Garbage Collection on CI.
2019-10-24 21:51:13 +09:00
peaceiris
3fe8ef06d5 github: Add CODEOWNERS 2019-10-24 06:03:40 +09:00
peaceiris
3e1caf266f deps: update 2019-10-23 20:02:44 +09:00
peaceiris
827a8f8ea5 deps: Add dependabot config 2019-10-23 20:01:55 +09:00
peaceiris
7ed9704167 deps: update 2019-10-22 15:20:10 +09:00
dependabot-preview[bot]
967e91f479 build(deps): bump @actions/core from 1.1.3 to 1.2.0 (#68)
* build(deps): bump @actions/core from 1.1.3 to 1.2.0

Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.1.3 to 1.2.0.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/master/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* deps: npm run build
2019-10-22 00:47:05 +09:00
peaceiris
46f4f706ee docs: update 2019-10-19 16:52:57 +09:00
peaceiris
5d81587f8c docs: Remove the link to actions tab
We need to login to access the actions tab.

https://github.com/sdras/awesome-actions/issues/232
2019-10-17 16:31:56 +09:00
dependabot-preview[bot]
71b8a771a4 build(deps-dev): bump @types/node from 12.11.0 to 12.11.1 (#66)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 12.11.0 to 12.11.1.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-16 15:38:12 +09:00
peaceiris
432b4df64a deps: update 2019-10-16 07:42:58 +09:00
peaceiris
199ebd1829 deps: update 2019-10-15 16:15:10 +09:00
peaceiris
9582ca51e5 docs: update workflow example, enhance build step 2019-10-14 21:57:26 +09:00
peaceiris
79ff7701be deps: update 2019-10-14 13:29:11 +09:00
peaceiris
ed1ba0af60 deps: update 2019-10-10 15:25:52 +09:00
peaceiris
c57482c110 deps: update 2019-10-09 14:03:54 +09:00
peaceiris
4e9981b947 chore: delete line 2019-10-09 11:49:24 +09:00
peaceiris
7082e0fbec config: Add .envrc 2019-10-09 11:46:06 +09:00
Shohei Ueda
3e55082b3f gha: Use setup-node (#58)
* config: Add .nvmrc
* gha: Add setup-node step
* gha: Add step to read .nvmrc

Close #55
2019-10-09 00:20:05 +09:00
imgbot[bot]
839eb279b0 [ImgBot] Optimize images (#56)
/images/ogp.svg -- 257.54kb -> 257.51kb (0.01%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
2019-10-08 14:01:01 +09:00
peaceiris
a02eaa1734 deps: update 2019-10-08 13:47:18 +09:00
peaceiris
fa565fb82d docs: update workflow example 2019-10-07 20:15:02 +09:00
peaceiris
7404f29555 chore: update .gitignore 2019-10-07 15:10:37 +09:00
peaceiris
7b66ed001b docs: update tag 2019-10-07 00:19:53 +09:00
peaceiris
64951c5a73 docs: update 2019-10-07 00:11:15 +09:00
peaceiris
35c74b6a6a deps: update 2019-10-04 12:19:43 +09:00
peaceiris
b5fb138703 meta: Update description 2019-10-03 11:35:41 +09:00
Shohei Ueda
6f6a564fad Deps: update (#53)
* deps: update

* deps: update node_modules
2019-10-02 10:58:52 +09:00
peaceiris
cd3751ce70 gha: enhance trigger 2019-10-01 20:10:45 +09:00
peaceiris
07e434d37c deps: update lint-staged 2019-10-01 14:54:03 +09:00
peaceiris
1405de8b20 deps: update eslint 2019-10-01 11:01:26 +09:00
peaceiris
7346c7bdad deps: update eslint 2019-09-29 14:08:38 +09:00
peaceiris
f1ac6bf271 deps: update husky 2019-09-28 11:19:42 +09:00
peaceiris
c7b570bed5 deps: update 2019-09-26 19:48:38 +09:00
Shohei Ueda
3ae7dd1270 deps: update (#52)
#50
2019-09-26 14:50:12 +09:00
peaceiris
9fdb1cb749 docs: update tag of peaceiris/actions-gh-pages to v2.4.0 2019-09-25 12:47:37 +09:00
peaceiris
e2b52b7b4d docs: update tag to v2.2.1 2019-09-25 12:44:14 +09:00
Shohei Ueda
8e97852759 Deps: update (#49)
* deps: update
* deps: update node_modules

#46 #47 #48
2019-09-25 12:40:38 +09:00
peaceiris
b46070141b docs: Add submodules to actions/checkout
https://github.com/peaceiris/actions-hugo/issues/42
2019-09-24 07:31:06 +09:00
peaceiris
a1adb3bb7b gha: remove paths 2019-09-23 14:35:33 +09:00
peaceiris
fbb67a3359 docs: update tag 2019-09-23 14:10:41 +09:00
peaceiris
2e5b1b84d6 deps: upgrade lint-staged 9.3.0 2019-09-23 12:36:26 +09:00
peaceiris
6d819cab4c gha: fix pull_request trigger 2019-09-23 11:33:57 +09:00
Shohei Ueda
a6d33f08ac config: enhance tsconfig.json (#44)
* config: enhance tsconfig.json (Set sourceMap and removeComments to true)
* gha: Add pull_request trigger, close #43
* config: Add waring emoji
2019-09-23 10:58:19 +09:00
Shohei Ueda
71663ea875 gha: use paths instead of paths-ignore (#41)
* gha: use paths instead of paths-ignore
* docs: update from 3 sec to 4 sec
* ci: update husky post-commit hook
2019-09-22 15:45:20 +09:00
Shohei Ueda
d7d48e3009 Refactor: enhance Hugo version dumping (#39) 2019-09-22 10:24:28 +09:00
peaceiris
39aa1b7d04 docs: Add Table of Contents 2019-09-22 09:43:11 +09:00
Shohei Ueda
b10091c0dc Enhance: workflow (#38)
* gha: Add paths-ignore
* docs: enhance
2019-09-22 09:37:17 +09:00
peaceiris
824187d952 fix: npm run tsc 2019-09-22 08:42:53 +09:00
Shohei Ueda
e194c83989 Refactor: remove Golang and Git dumping (#37)
* ci: setup lint-staged
* refactor: remove golang and git dumping
2019-09-22 08:13:23 +09:00
peaceiris
c3970dfbdd config: update meta data 2019-09-21 22:45:31 +09:00
peaceiris
082748017c deps: update @actions/core 2019-09-21 11:28:40 +09:00
dependabot-preview[bot]
79d6bc5f6e build(deps): bump @actions/core from 1.1.0 to 1.1.1 (#35)
Bumps [@actions/core](https://github.com/actions/toolkit) from 1.1.0 to 1.1.1.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Commits](https://github.com/actions/toolkit/compare/@actions/core@1.1.0...@actions/tool-cache@1.1.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-09-21 11:24:42 +09:00
peaceiris
8f1aef7e73 docs: update peaceiris/actions-hugo@v2.2.0 2019-09-21 10:46:47 +09:00
Shohei Ueda
dc8541739a Feat: Support macOS and Windows, migrate JavaScript to TypeScript (#32)
- Support macOS and Windows (Close #24 )
- Refactoring
  - Error handling
  - TypeScript
- Prettier (Close #29 )
- GHA: Add upload-artifact step for test coverage
- deps: Install husky
2019-09-21 10:41:21 +09:00
Shohei Ueda
4d54b90c0e Refactor: directory structure (#31)
* config: update version
* refactor: move source codes to lib directory, Close #30
* refactor: move test code
2019-09-18 07:32:17 +09:00
peaceiris
25a3456032 config: update version 2019-09-18 05:14:10 +09:00
peaceiris
4f371785be docs: update v2.1.0 2019-09-18 04:23:27 +09:00
peaceiris
3bbd6d1917 docs: update readme 2019-09-18 04:18:10 +09:00
Shohei Ueda
d46d0aa12e Refactor: Get the latest version from Homebrew (#28)
Refactoring

* feat: Add reject to Promise
* feat: Add printing inputs
* feat: Add error handling to getLatestVersion()
* feat: show version of Hugo, Go, and Git (Close #23)
* refactor: Get the latest version from Homebrew (Close #26)
* refactor: enhance error message of promise reject

Enhancement for workflow

* gha: Add deps (test-prod job needs test job)
* gha: Fix matrix testing
* gha: comment out Build production step
* gha: remove Dump step

Update README

* docs: update readme
2019-09-18 04:11:47 +09:00
Shohei Ueda
85171ece4e refactor: Add process.env.HOME (#27) 2019-09-17 23:20:28 +09:00
peaceiris
624c2a083b docs: Add description about this action 2019-09-17 20:39:59 +09:00
peaceiris
7a9975a8b1 deps: upgrade eslint to 6.4.0 2019-09-16 15:20:59 +09:00
peaceiris
c635fd9746 docs: Fix path to GitHub Actions status badge 2019-09-16 08:45:47 +09:00
peaceiris
19661a5c56 gha: fix action name 2019-09-16 08:33:49 +09:00
peaceiris
c4f3b85a0d gha: Add branding 2019-09-16 08:33:04 +09:00
Shohei Ueda
68358aa004 Migrate javascript action (#21) 2019-09-16 08:27:57 +09:00
peaceiris
ded0a1ada3 gha: update workflow trigger 2019-09-15 05:27:30 +09:00
peaceiris
b7618725f9 deps: Upgrade Hugo to v0.58.2 2019-09-15 05:24:34 +09:00
peaceiris
38f4938bc6 add: github repository card of peaceiris/actions-gh-pages 2019-09-10 01:25:39 +09:00
peaceiris
d8740dd53b gha: add hadolint job to check Dockerfile 2019-09-08 21:18:27 +09:00
peaceiris
2d9de755b5 upgrade: Hugo to v0.58.1 2019-09-08 18:03:21 +09:00
peaceiris
eb817c8e92 update(readme): peaceiris/actions-gh-pages to v2.2.0 2019-09-08 17:54:44 +09:00
peaceiris
672bb33daa use: ACTIONS_DEPLOY_KEY 2019-09-06 03:09:36 +09:00
peaceiris
26378c050c add: action.yml 2019-09-06 03:07:42 +09:00
peaceiris
dd1c91caf4 update: peaceiris/actions-gh-pages to v2.1.0 2019-09-06 00:38:20 +09:00
peaceiris
db1611bb0d gha: remove if statement from steps 2019-09-05 01:50:24 +09:00
Shohei Ueda
03083c655e Release v0.58.0 (#17)
* upgrade: Hugo to v0.58.0
* fix: push workflow
* remove: tag filter from push workflow
* upgrade: base image golang to 1.13.0

- https://gohugo.io/news/0.58.0-relnotes/
- https://discourse.gohugo.io/t/hugo-benchmarks-go-1-12-vs-go-1-13/20572
2019-09-05 01:43:34 +09:00
peaceiris
3439246b4a fix: FUNDING.yml 2019-09-04 22:24:58 +09:00
peaceiris
b2c2768a0c add: Docker Hub Build Status badge 2019-09-02 19:23:11 +09:00
peaceiris
ff9b678d15 rename: example workflow name 2019-08-22 05:03:19 +09:00
peaceiris
a2e4fdca67 enhance: yaml example 2019-08-22 02:54:38 +09:00
Shohei Ueda
55565fc0f6 Release v0.57.2 (#14)
* enhance: GitHub Actions

* upgrade: hugo to v0.57.2

* enhance: Pull Request template
2019-08-20 00:52:44 +09:00
Shohei Ueda
79fb16c8e4 Release: v0.57.1 (#13)
* upgrade: hugo to v0.57.1

* enhance: .github/PULL_REQUEST_TEMPLATE.md
2019-08-16 20:45:05 +09:00
peaceiris
d08dcd0297 fix: CI 2019-08-16 00:29:52 +09:00
peaceiris
1daa8a255f enhance: test job 2019-08-16 00:08:44 +09:00
peaceiris
46fbb349ce add: CI filters 2019-08-15 23:48:21 +09:00
Shohei Ueda
d079faea7e enhance: GitHub Actions settings (#11) 2019-08-15 21:26:43 +09:00
Shohei Ueda
b9842008ed enhance: GitHub Actions settings (#10) 2019-08-15 21:19:55 +09:00
Shohei Ueda
021efbc871 add: filter to prevent CI when branch are deleted (#9) 2019-08-15 20:43:36 +09:00
Shohei Ueda
b8232e8a2c Release v0.57.0 (#8)
* migrate: GitHub Actions beta v2 (HCL to YAML)

* add: Pull Request template

* upgrade: actions

* enhance: GitHub Actions config

* update: readme

* remove: patreon image
2019-08-15 20:26:15 +09:00
Shohei Ueda
b101526f7f upgrade: hugo to v0.56.3 (#6) 2019-07-31 22:23:35 +09:00
Shohei Ueda
f7fd45cb9e release: v0.56.2 (#5)
* change: install from binary

* update: tag on readme

* add: move hugo binary under GOPATH

* upgrade: hugo to v0.56.2
2019-07-30 19:43:01 +09:00
Shohei Ueda
09ca2911f5 v0.56.1 (#4)
* upgrade: hugo to v0.56.1

* update: readme for v0.56.1
2019-07-29 08:27:02 +09:00
Shohei Ueda
105e2e8ee3 Hugo Modules (#3)
* change: base image debian:9-slim to golang:1.12.7-buster

* update: tag on readme
2019-07-27 19:29:29 +09:00
33 changed files with 12540 additions and 112 deletions

9
.dependabot/config.yml Normal file
View File

@@ -0,0 +1,9 @@
version: 1
update_configs:
- package_manager: "javascript"
directory: "/"
update_schedule: "weekly"
default_labels:
- "dependencies"
commit_message:
prefix: "deps"

View File

@@ -1,5 +0,0 @@
.git
.github
LICENSE
README.md
images

9
.editorconfig Normal file
View File

@@ -0,0 +1,9 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

3
.envrc Normal file
View File

@@ -0,0 +1,3 @@
nvmrc=~/.nvm/nvm.sh
source $nvmrc
nvm use

19
.eslintrc.json Normal file
View File

@@ -0,0 +1,19 @@
{
"env": {
"commonjs": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2019
},
"rules": {
}
}

3
.github/CODEOWNERS vendored Normal file
View File

@@ -0,0 +1,3 @@
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
* @peaceiris

8
.github/FUNDING.yml vendored
View File

@@ -1,8 +0,0 @@
# These are supported funding model platforms
github: peaceiris
patreon: peaceiris
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
custom: # Replace with a single custom sponsorship URL

31
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,31 @@
---
name: Bug report
about: Create a report to help us improve
title: 'Bug: This is a sample issue title'
labels: bug
assignees: peaceiris
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Your YAML file**
- A link to your repository
- A link to your YAML file
**Additional context**
Add any other context about the problem here.

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: GitHub Actions Community Forum
url: https://github.community/t5/GitHub-Actions/bd-p/actions
about: Please ask questions about GitHub Actions here.
- name: Hugo Community Forum
url: https://discourse.gohugo.io/
about: Please ask questions about Hugo here.

View File

@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: 'feat: This is a sample title'
labels: request
assignees: peaceiris
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@@ -1,9 +0,0 @@
workflow "Main workflow" {
on = "push"
resolves = ["docker-build"]
}
action "docker-build" {
uses = "actions/docker/cli@master"
args = "build -t peaceiris/actions-hugo ."
}

73
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,73 @@
name: 'Test'
on:
pull_request:
types: [opened, synchronize]
paths-ignore:
- '**.md'
push:
paths-ignore:
- '**.md'
branches:
- master
jobs:
test:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Read .nvmrc
run: echo ::set-output name=NVMRC::$(cat .nvmrc)
id: nvm
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'
- name: Cache
uses: actions/cache@v1.0.1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- run: npm ci
- run: npm run format:check
- run: npm run lint
- run: npm test
- name: Upload test coverage
uses: actions/upload-artifact@master
with:
name: coverage
path: coverage
test-prod:
runs-on: ${{ matrix.os }}
needs: test
strategy:
matrix:
os: ['ubuntu-18.04', 'macos-latest', 'windows-latest']
hugo-version: ['latest', '0.57.2']
extended: [true, false]
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Test action
uses: ./
with:
hugo-version: ${{ matrix.hugo-version }}
extended: ${{ matrix.extended }}

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
coverage
.npm
.eslintcache
.env
node_modules

1
.nvmrc Normal file
View File

@@ -0,0 +1 @@
12.13.0

11
.prettierrc.json Normal file
View File

@@ -0,0 +1,11 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript"
}

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}

View File

@@ -1,27 +0,0 @@
FROM debian:9-slim
LABEL "com.github.actions.name"="Hugo extended action"
LABEL "com.github.actions.description"="GitHub Actions for Hugo extended version"
LABEL "com.github.actions.icon"="package"
LABEL "com.github.actions.color"="yellow"
LABEL "repository"="https://github.com/peaceiris/actions-hugo"
LABEL "homepage"="https://github.com/peaceiris/actions-hugo"
LABEL "maintainer"="peaceiris"
ENV HUGO_VERSION='0.56.0'
ENV HUGO_NAME="hugo_extended_${HUGO_VERSION}_Linux-64bit"
ENV HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${HUGO_NAME}.deb"
ENV BUILD_DEPS="wget ca-certificates"
RUN apt-get update && \
apt-get install -y --no-install-recommends git ${BUILD_DEPS} && \
wget "${HUGO_URL}" && \
apt-get install -y --no-install-recommends "./${HUGO_NAME}.deb" && \
rm -rf "./${HUGO_NAME}.deb" "${HUGO_NAME}" && \
apt-get remove -y ${BUILD_DEPS} && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENTRYPOINT [ "/usr/local/bin/hugo" ]

124
README.md
View File

@@ -1,61 +1,125 @@
[![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)
[![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)
[![CodeFactor](https://www.codefactor.io/repository/github/peaceiris/actions-hugo/badge)](https://www.codefactor.io/repository/github/peaceiris/actions-hugo)
<img width="400" alt="GitHub Actions for Hugo extended" src="./images/ogp.svg">
<img width="400" alt="GitHub Actions for Hugo" src="./images/ogp.svg">
## GitHub Actions for Hugo extended
## GitHub Actions for Hugo extended and Modules
- [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 (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.)
| OS (runs-on) | ubuntu-18.04 | macos-latest | windows-2019 |
|---|:---:|:---:|:---:|
| Support | ✅️ | ✅️ | ✅️ |
| Hugo type | Hugo Extended | Hugo Modules | Latest Hugo |
|---|:---:|:---:|:---:|
| Support | ✅️ | ✅️ | ✅️ |
<!-- 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)
- [License](#license)
- [About the author](#about-the-author)
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## Getting started
### Create `main.workflow`
### ⭐️ Create your workflow
An example with [GitHub Actions for deploying to GitHub Pages with Static Site Generators]
An example workflow `.github/workflows/gh-pages.yml` with [GitHub Actions for GitHub Pages]
[GitHub Actions for deploying to GitHub Pages with Static Site Generators]: https://github.com/peaceiris/actions-gh-pages
[GitHub Actions for GitHub Pages]: https://github.com/peaceiris/actions-gh-pages
[![peaceiris/actions-gh-pages - GitHub](https://gh-card.dev/repos/peaceiris/actions-gh-pages.svg?fullname)](https://github.com/peaceiris/actions-gh-pages)
![peaceiris/actions-hugo latest version](https://img.shields.io/github/release/peaceiris/actions-hugo.svg?label=peaceiris%2Factions-hugo)
![peaceiris/actions-gh-pages latest version](https://img.shields.io/github/release/peaceiris/actions-gh-pages.svg?label=peaceiris%2Factions-gh-pages)
```hcl
workflow "GitHub Pages" {
on = "push"
resolves = ["deploy"]
}
```yaml
name: github pages
action "is-branch-master" {
uses = "actions/bin/filter@master"
args = "branch master"
}
on:
push:
branches:
- master
action "build" {
needs = "is-branch-master"
uses = "peaceiris/actions-hugo@v0.56.0"
args = ["--gc", "--minify", "--cleanDestinationDir"]
}
jobs:
build-deploy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
# with:
# submodules: true
action "deploy" {
needs = "build"
uses = "peaceiris/actions-gh-pages@v1.0.1"
env = {
PUBLISH_DIR = "./public"
PUBLISH_BRANCH = "gh-pages"
}
secrets = ["ACTIONS_DEPLOY_KEY"]
}
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2.2.2
with:
hugo-version: '0.58.3'
# extended: true
- name: Build
run: hugo --minify
- name: Deploy
uses: peaceiris/actions-gh-pages@v2.5.0
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./public
```
## Options
### ⭐️ Use Hugo extended
Set `extended: true` to use a Hugo extended version.
```yaml
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2.2.2
with:
hugo-version: '0.58.3'
extended: true
```
### ⭐️ Use the latest version of Hugo
Set `hugo-version: 'latest'` to use the latest version of Hugo.
```yaml
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2.2.2
with:
hugo-version: 'latest'
```
This action fetches the latest version of Hugo by [hugo | Homebrew Formulae](https://formulae.brew.sh/formula/hugo)
## License
[MIT License - peaceiris/actions-hugo]
- [MIT License - peaceiris/actions-hugo]
[MIT License - peaceiris/actions-hugo]: https://github.com/peaceiris/actions-hugo/blob/master/LICENSE
@@ -64,5 +128,3 @@ action "deploy" {
## About the author
- [peaceiris's homepage](https://peaceiris.com/)
<a href="https://www.patreon.com/peaceiris"><img src="./images/patreon.jpg" alt="peaceiris - Patreon" width="150px"></a>

18
__tests__/get-os.test.ts Normal file
View File

@@ -0,0 +1,18 @@
import getOS from '../src/get-os';
describe('getOS', () => {
test('test', () => {
expect(getOS('linux')).toBe('Linux');
expect(getOS('darwin')).toBe('macOS');
expect(getOS('win32')).toBe('Windows');
});
test('test exception', () => {
// expect(() => {
// getOS("win32");
// }).toThrowError("Windows is not supported");
expect(() => {
getOS('centos');
}).toThrowError('centos is not supported');
});
});

22
__tests__/get-url.test.ts Normal file
View File

@@ -0,0 +1,22 @@
import getURL from '../src/get-url';
describe('getURL()', () => {
test('test', () => {
const baseURL =
'https://github.com/gohugoio/hugo/releases/download/v0.58.2';
const urlLinux = `${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`;
const urlLinuxExtended = `${baseURL}/hugo_extended_0.58.2_Linux-64bit.tar.gz`;
const urlMacOS = `${baseURL}/hugo_0.58.2_macOS-64bit.tar.gz`;
const urlWindows = `${baseURL}/hugo_0.58.2_Windows-64bit.zip`;
expect(getURL('Linux', 'false', '0.58.2')).toBe(urlLinux);
expect(getURL('Linux', 'true', '0.58.2')).toBe(urlLinuxExtended);
expect(getURL('macOS', 'false', '0.58.2')).toBe(urlMacOS);
expect(getURL('Windows', 'false', '0.58.2')).toBe(urlWindows);
});
// test("test exception", () => {
// expect(() => {
// getURL("Linux", "hoge", "0.58.2");
// }).toThrowError("Invalid input (extended): hoge");
// });
});

18
action.yml Normal file
View File

@@ -0,0 +1,18 @@
name: 'Hugo setup'
description: 'GitHub Actions for Hugo ⚡️ Setup Hugo quickly and build your site fast. Hugo extended and Hugo Modules are supported.'
author: 'peaceiris'
inputs:
hugo-version:
description: 'The Hugo version to download (if necessary) and use. Example: 0.58.2'
required: false
default: 'latest'
extended:
description: 'Download (if necessary) and use Hugo extended version. Example: true'
required: false
default: 'false'
runs:
using: 'node12'
main: 'lib/index.js'
branding:
icon: 'package'
color: 'yellow'

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 258 KiB

After

Width:  |  Height:  |  Size: 258 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

11
jest.config.js Normal file
View File

@@ -0,0 +1,11 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}

5234
lib/index.js Normal file

File diff suppressed because it is too large Load Diff

6675
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

69
package.json Normal file
View File

@@ -0,0 +1,69 @@
{
"name": "hugo-action",
"version": "2.2.0",
"description": "Hugo setup action",
"main": "lib/index.js",
"scripts": {
"lint": "eslint ./src/**/*.ts",
"lint:fix": "eslint --fix ./src/**/*.ts",
"test": "jest --coverage --verbose",
"build": "ncc build ./src/index.ts -o lib",
"tsc": "tsc",
"format": "prettier --write **/*.ts",
"format:check": "prettier --check **/*.ts"
},
"husky": {
"skipCI": true,
"hooks": {
"pre-commit": "lint-staged",
"post-commit": "npm run build && echo '⚠️ Do not forget to Commit and Push ./lib/index.js'"
}
},
"lint-staged": {
"src/**/*.ts": [
"prettier --check",
"eslint",
"jest --bail --findRelatedTests",
"git add"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/peaceiris/actions-hugo.git"
},
"keywords": [
"GitHub",
"Actions",
"JavaScript",
"TypeScript",
"Hugo",
"Setup"
],
"author": "peaceiris",
"license": "MIT",
"bugs": {
"url": "https://github.com/peaceiris/actions-hugo/issues"
},
"homepage": "https://github.com/peaceiris/actions-hugo#readme",
"dependencies": {
"@actions/core": "^1.2.0",
"@actions/exec": "^1.0.1",
"@actions/io": "^1.0.1",
"@actions/tool-cache": "^1.1.2",
"xmlhttprequest": "^1.8.0"
},
"devDependencies": {
"@types/jest": "^24.0.23",
"@types/node": "^12.12.8",
"@typescript-eslint/parser": "^2.7.0",
"@zeit/ncc": "^0.20.5",
"eslint": "^6.6.0",
"husky": "^3.0.9",
"jest": "^24.9.0",
"jest-circus": "^24.9.0",
"lint-staged": "^9.4.3",
"prettier": "1.19.1",
"ts-jest": "^24.1.0",
"typescript": "^3.7.2"
}
}

19
src/get-latest-version.ts Normal file
View File

@@ -0,0 +1,19 @@
const XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
export default function getLatestVersion(): Promise<string> {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
const url: string = 'https://formulae.brew.sh/api/formula/hugo.json';
xhr.open('GET', url);
xhr.send();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4 && xhr.status === 200) {
const result = JSON.parse(xhr.responseText);
const latestVersion: string = result.versions.stable;
resolve(latestVersion);
} else if (xhr.readyState === 4 && xhr.status !== 200) {
reject(`ERROR: got status ${xhr.status} of ${url}`);
}
};
});
}

12
src/get-os.ts Normal file
View File

@@ -0,0 +1,12 @@
export default function getOS(platform: string) {
if (platform === 'linux') {
return 'Linux';
} else if (platform === 'darwin') {
return 'macOS';
} else if (platform === 'win32') {
return 'Windows';
// throw new Error("Windows is not supported");
} else {
throw new Error(`${platform} is not supported`);
}
}

31
src/get-url.ts Normal file
View File

@@ -0,0 +1,31 @@
export default function getURL(
os: string,
extended: string,
version: string
): string {
const extendedStr = (extended: string) => {
if (extended === 'true') {
return 'extended_';
} else {
return '';
// } else {
// throw new Error(`Invalid input (extended): ${extended}`);
}
};
const ext = (os: string) => {
if (os === 'Windows') {
return 'zip';
} else {
return 'tar.gz';
}
};
const hugoName: string = `hugo_${extendedStr(
extended
)}${version}_${os}-64bit`;
const baseURL: string = 'https://github.com/gohugoio/hugo/releases/download';
const url: string = `${baseURL}/v${version}/${hugoName}.${ext(os)}`;
return url;
}

37
src/index.ts Normal file
View File

@@ -0,0 +1,37 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import getLatestVersion from './get-latest-version';
import installer from './installer';
// most @actions toolkit packages have async methods
async function run() {
const dump = async () => {
// Show version
await exec.exec('hugo version');
};
try {
const hugoVersion: string = core.getInput('hugo-version');
if (hugoVersion === '' || hugoVersion === 'latest') {
getLatestVersion().then(
async function(latestVersion): Promise<void> {
console.log(`Hugo version: ${latestVersion} (${hugoVersion})`);
await installer(latestVersion);
await dump();
},
function(error) {
core.setFailed(error);
}
);
} else {
console.log(`Hugo version: ${hugoVersion}`);
await installer(hugoVersion);
await dump();
}
} catch (error) {
core.setFailed(error.message);
}
}
run();

42
src/installer.ts Normal file
View File

@@ -0,0 +1,42 @@
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import * as io from '@actions/io';
import getOS from './get-os';
import getURL from './get-url';
export default async function installer(version: string) {
try {
const extended: string = core.getInput('extended');
console.log(`Hugo extended: ${extended}`);
const osName: string = getOS(process.platform);
console.log(`Operating System: ${osName}`);
const hugoURL: string = getURL(osName, extended, version);
core.debug(`hugoURL: ${hugoURL}`);
const hugoPath: string = `${process.env.HOME}/bin`;
await io.mkdirP(hugoPath);
core.addPath(hugoPath);
// Download and extract Hugo binary
const hugoAssets: string = await tc.downloadTool(hugoURL);
let hugoBin: string = '';
if (osName === 'Windows') {
const hugoExtractedFolder: string = await tc.extractZip(
hugoAssets,
'/tmp'
);
hugoBin = `${hugoExtractedFolder}/hugo.exe`;
} else {
const hugoExtractedFolder: string = await tc.extractTar(
hugoAssets,
'/tmp'
);
hugoBin = `${hugoExtractedFolder}/hugo`;
}
await io.mv(hugoBin, hugoPath);
} catch (error) {
core.setFailed(error.message);
}
}

63
tsconfig.json Normal file
View File

@@ -0,0 +1,63 @@
{
"compilerOptions": {
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./lib", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
"removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
// "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
},
"exclude": ["node_modules", "**/*.test.ts"]
}