Skip to content

Commit

Permalink
Enable passing arbitrary options to Hugo build
Browse files Browse the repository at this point in the history
Merge pull request #6 from victoriadrake/Bas-Man-Add-ENV-Arguments-to-hugo
  • Loading branch information
victoriadrake committed Jul 19, 2020
2 parents 16b6bda + df6fbd6 commit 17c0477
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ This action expects variables for:
- `DEST`, the name of the destination directory you would like the site to build to,
- `TOKEN`, in the form `${{ secrets.TOKEN }}` assuming `TOKEN` is the name you've used.

See `env` in the below example for how to set these in your workflow YAML file.

You can optionally set an environment variable `HUGO_ARGS` under the "Build and deploy" step. This allows passing one or more arbitrary [options](https://gohugo.io/commands/hugo/#options) to the `hugo` build command. See `man hugo` on your system for options. Some examples include:

- `HUGO_ARGS: '--minify'`
- `HUGO_ARGS: '--enableGitInfo --ignoreCache'`

Here is an example workflow file that uses this action on any `push` event to the `master` branch:

```yml
Expand All @@ -54,6 +61,8 @@ jobs:
with:
fetch-depth: 1
- name: 🚀 Build and deploy
#env:
# HUGO_ARGS:
uses: victoriadrake/hugo-remote@master
```
Expand Down
2 changes: 1 addition & 1 deletion action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if [ -d "${DEST}" ]; then
fi

echo '🍳 Build site'
hugo -d ${DEST}
hugo ${HUGO_ARGS:-""} -d ${DEST}

echo '🎁 Publish to remote repository'
cd ${DEST}
Expand Down
2 changes: 1 addition & 1 deletion hugo-remote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
rm -rf ${DEST}/*
fi
- name: 🍳 Build site
run: hugo -d ${DEST}
run: hugo ${HUGO_ARGS:-""} -d ${DEST}
- name: 🎁 Publish to remote repository
env:
TOKEN: ${{ secrets.TOKEN }}
Expand Down

0 comments on commit 17c0477

Please sign in to comment.