mirror of
https://github.com/peaceiris/actions-hugo.git
synced 2026-01-25 20:32:19 +01:00
Compare commits
105 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab3f21340f | ||
|
|
3ab6d78f1e | ||
|
|
007cfe211d | ||
|
|
1d2fa2a9c3 | ||
|
|
10b88ee9bf | ||
|
|
b93236ba6f | ||
|
|
535d0e0aa9 | ||
|
|
90fbf33ad8 | ||
|
|
d3401a30a3 | ||
|
|
eb85852ce3 | ||
|
|
3c10f8d88a | ||
|
|
0de12a826f | ||
|
|
5bb02a4a7d | ||
|
|
9aa9bf7c5a | ||
|
|
3be578e3c5 | ||
|
|
ec916d70ad | ||
|
|
d88559854c | ||
|
|
2965e59bb8 | ||
|
|
f0004ebb52 | ||
|
|
0101f0a550 | ||
|
|
c31a671975 | ||
|
|
78c603eb60 | ||
|
|
bbc02a7bb6 | ||
|
|
8e53828e04 | ||
|
|
3fe8ef06d5 | ||
|
|
3e1caf266f | ||
|
|
827a8f8ea5 | ||
|
|
7ed9704167 | ||
|
|
967e91f479 | ||
|
|
46f4f706ee | ||
|
|
5d81587f8c | ||
|
|
71b8a771a4 | ||
|
|
432b4df64a | ||
|
|
199ebd1829 | ||
|
|
9582ca51e5 | ||
|
|
79ff7701be | ||
|
|
ed1ba0af60 | ||
|
|
c57482c110 | ||
|
|
4e9981b947 | ||
|
|
7082e0fbec | ||
|
|
3e55082b3f | ||
|
|
839eb279b0 | ||
|
|
a02eaa1734 | ||
|
|
fa565fb82d | ||
|
|
7404f29555 | ||
|
|
7b66ed001b | ||
|
|
64951c5a73 | ||
|
|
35c74b6a6a | ||
|
|
b5fb138703 | ||
|
|
6f6a564fad | ||
|
|
cd3751ce70 | ||
|
|
07e434d37c | ||
|
|
1405de8b20 | ||
|
|
7346c7bdad | ||
|
|
f1ac6bf271 | ||
|
|
c7b570bed5 | ||
|
|
3ae7dd1270 | ||
|
|
9fdb1cb749 | ||
|
|
e2b52b7b4d | ||
|
|
8e97852759 | ||
|
|
b46070141b | ||
|
|
a1adb3bb7b | ||
|
|
fbb67a3359 | ||
|
|
2e5b1b84d6 | ||
|
|
6d819cab4c | ||
|
|
a6d33f08ac | ||
|
|
71663ea875 | ||
|
|
d7d48e3009 | ||
|
|
39aa1b7d04 | ||
|
|
b10091c0dc | ||
|
|
824187d952 | ||
|
|
e194c83989 | ||
|
|
c3970dfbdd | ||
|
|
082748017c | ||
|
|
79d6bc5f6e | ||
|
|
8f1aef7e73 | ||
|
|
dc8541739a | ||
|
|
4d54b90c0e | ||
|
|
25a3456032 | ||
|
|
4f371785be | ||
|
|
3bbd6d1917 | ||
|
|
d46d0aa12e | ||
|
|
85171ece4e | ||
|
|
624c2a083b | ||
|
|
7a9975a8b1 | ||
|
|
c635fd9746 | ||
|
|
19661a5c56 | ||
|
|
c4f3b85a0d | ||
|
|
68358aa004 | ||
|
|
ded0a1ada3 | ||
|
|
b7618725f9 | ||
|
|
38f4938bc6 | ||
|
|
d8740dd53b | ||
|
|
2d9de755b5 | ||
|
|
eb817c8e92 | ||
|
|
672bb33daa | ||
|
|
26378c050c | ||
|
|
dd1c91caf4 | ||
|
|
db1611bb0d | ||
|
|
03083c655e | ||
|
|
3439246b4a | ||
|
|
b2c2768a0c | ||
|
|
ff9b678d15 | ||
|
|
a2e4fdca67 | ||
|
|
55565fc0f6 |
9
.dependabot/config.yml
Normal file
9
.dependabot/config.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
version: 1
|
||||
update_configs:
|
||||
- package_manager: "javascript"
|
||||
directory: "/"
|
||||
update_schedule: "weekly"
|
||||
default_labels:
|
||||
- "dependencies"
|
||||
commit_message:
|
||||
prefix: "deps"
|
||||
@@ -1,5 +0,0 @@
|
||||
.git
|
||||
.github
|
||||
LICENSE
|
||||
README.md
|
||||
images
|
||||
9
.editorconfig
Normal file
9
.editorconfig
Normal 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
|
||||
19
.eslintrc.json
Normal file
19
.eslintrc.json
Normal 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
3
.github/CODEOWNERS
vendored
Normal 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
8
.github/FUNDING.yml
vendored
@@ -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
31
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal 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
8
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal 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.
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal 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.
|
||||
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,3 +0,0 @@
|
||||
- [ ] upgrade: hugo to ``
|
||||
- [ ] update: tag on readme
|
||||
- [ ] release: `` with **master** branch
|
||||
18
.github/workflows/push.yml
vendored
18
.github/workflows/push.yml
vendored
@@ -1,18 +0,0 @@
|
||||
name: Push workflow
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- invalid-tag
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Docker build and print Hugo version
|
||||
if: github.event.deleted == false
|
||||
run: |
|
||||
docker build -t peaceiris/actions-hugo . &&
|
||||
docker run peaceiris/actions-hugo:latest version ||
|
||||
(echo -e "\e[31mfailed to build\e[m" && exit 1)
|
||||
73
.github/workflows/test.yml
vendored
Normal file
73
.github/workflows/test.yml
vendored
Normal 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
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
coverage
|
||||
.npm
|
||||
.eslintcache
|
||||
.env
|
||||
node_modules
|
||||
11
.prettierrc.json
Normal file
11
.prettierrc.json
Normal 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
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"git.ignoreLimitWarning": true
|
||||
}
|
||||
19
Dockerfile
19
Dockerfile
@@ -1,19 +0,0 @@
|
||||
FROM golang:1.12.7-buster
|
||||
|
||||
LABEL "com.github.actions.name"="Hugo action"
|
||||
LABEL "com.github.actions.description"="GitHub Actions for Hugo extended and Hugo Modules"
|
||||
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.57.1'
|
||||
ENV HUGO_NAME="hugo_extended_${HUGO_VERSION}_Linux-64bit"
|
||||
ENV HUGO_URL="https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/${HUGO_NAME}.tar.gz"
|
||||
RUN wget "${HUGO_URL}" && \
|
||||
tar -zxvf "${HUGO_NAME}.tar.gz" && \
|
||||
mv ./hugo /go/bin/
|
||||
|
||||
ENTRYPOINT [ "/go/bin/hugo" ]
|
||||
92
README.md
92
README.md
@@ -1,8 +1,10 @@
|
||||
[](https://github.com/peaceiris/actions-hugo/blob/master/LICENSE)
|
||||
[](https://github.com/peaceiris/actions-hugo/releases/latest)
|
||||
[](https://github.com/peaceiris/actions-hugo/releases)
|
||||

|
||||
[](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">
|
||||
|
||||
|
||||
|
||||
@@ -10,21 +12,49 @@
|
||||
|
||||
- [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 (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 `.github/workflows/push.yml`
|
||||
### ⭐️ 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
|
||||
|
||||
[](https://github.com/peaceiris/actions-gh-pages)
|
||||
|
||||

|
||||

|
||||
|
||||
```yaml
|
||||
name: Main workflow
|
||||
name: github pages
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -33,24 +63,60 @@ on:
|
||||
|
||||
jobs:
|
||||
build-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: build
|
||||
uses: peaceiris/actions-hugo@v0.57.1
|
||||
# with:
|
||||
# submodules: true
|
||||
|
||||
- name: Setup Hugo
|
||||
uses: peaceiris/actions-hugo@v2.2.2
|
||||
with:
|
||||
args: --gc --minify --cleanDestinationDir
|
||||
- name: deploy
|
||||
uses: peaceiris/actions-gh-pages@v1.1.0
|
||||
if: contains(github.ref, 'master')
|
||||
hugo-version: '0.58.3'
|
||||
# extended: true
|
||||
|
||||
- name: Build
|
||||
run: hugo --minify
|
||||
|
||||
- name: Deploy
|
||||
uses: peaceiris/actions-gh-pages@v2.5.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
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]
|
||||
|
||||
18
__tests__/get-os.test.ts
Normal file
18
__tests__/get-os.test.ts
Normal 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
22
__tests__/get-url.test.ts
Normal 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
18
action.yml
Normal 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 |
11
jest.config.js
Normal file
11
jest.config.js
Normal 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
5234
lib/index.js
Normal file
File diff suppressed because it is too large
Load Diff
6675
package-lock.json
generated
Normal file
6675
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
69
package.json
Normal file
69
package.json
Normal 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
19
src/get-latest-version.ts
Normal 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
12
src/get-os.ts
Normal 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
31
src/get-url.ts
Normal 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
37
src/index.ts
Normal 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
42
src/installer.ts
Normal 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
63
tsconfig.json
Normal 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"]
|
||||
}
|
||||
Reference in New Issue
Block a user