Some advice needed using BUILD_ONLY with BUILD_FLAGS
TonySpegel opened this issue · comments
Hi there,
first of all: thank you for this action - I've used it a couple of times for my personal website.
I really like using Zola but there's one thing it can't do: import npm modules.
In order to solve this I've figured that I would have to use some kind of bundler - I've picked RollUp to do so.
This also means that I have to bundle everything after building zola and before deploying.
Luckily your action has a BUILD_ONLY
flag.
Here is what I thought I could do and tried:
- Build Zola into a directory called
dist
- Run RollUp in this directory to resolve npm imports
- Deploy that
When doing so I get this error:
error: Found argument '--config' which wasn't expected, or isn't valid in this context
My customized action looks like this:
on: push
name: Build, Bundle & Deploy
jobs:
build-bundle-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- run: mkdir dist
- name: Zola Build
uses: shalzz/zola-deploy-action@master
env:
# Target branch
PAGES_BRANCH: gh-pages
# Provide personal access token
BUILD_DIR: dist
BUILD_ONLY: true
BUILD_FLAGS: --config config.live.toml
TOKEN: ${{ secrets.GH_PAGES }}
- name: Install NPM dependencies & bundle w/ Rollup
uses: actions/setup-node@v2
with:
node-version: '16'
- run: npm install
- run: sudo npm run build-rollup-live
- run: |
cd dist
git init
git config user.name "GitHub Actions"
git config user.email "github-actions-bot@users.noreply.${GITHUB_HOSTNAME}"
git add .
git commit -m "Deploy ${TARGET_REPOSITORY} to ${TARGET_REPOSITORY}:$remote_branch"
git push --force "${remote_repo}" master:${remote_branch}
echo "Deploy complete"
So it's mostly like yours. As you can see I was trying to use BUILD_FLAGS
with the --config
flag and a config file.
The relevant part of this file looks like this:
base_url = 'https://tony-spegel.com'
output_dir = 'dist'
The npm script build-rollup-live
I'm trying to run does this: rollup --config rollup.config.live.js
The config which should be used here would be:
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
export default {
input: 'dist/index.js',
output: {
dir: 'dist/',
format: 'es',
sourcemap: false,
},
plugins: [
nodeResolve(),
replace({
preventAssignment: true,
}),
],
};
Can you help me out here? I'd really appreciate it if you can push me in the right direction or give me an advice.
Thank you and have a nice weekend, please tell me if I can add anything to make things clearer
Hi, so the reason --config
doesn't work with BUILD_FLAGS
is that it is a global option and BUILD_FLAGS
only take `zola build specific options:
$ zola build --help
zola-build
Deletes the output directory if there is one and builds the site
USAGE:
zola build [FLAGS] [OPTIONS]
FLAGS:
--drafts Include drafts when loading the site
-h, --help Prints help information
-V, --version Prints version information
OPTIONS:
-u, --base-url <base_url> Force the base URL to be that value (default to the one in config.toml)
-o, --output-dir <output_dir> Outputs the generated site in the given path (by default 'public' dir in project
root)
That means that --config
option needs to be before the build
command.
So for your use case I'd suggest that either use the default config.toml
for live deployment and something like config.debug.toml
for dev envirnoment and build by zola --config config.debug.toml build
Or if you need to override only two options (base_url and output_dir) you can do that by the build command options -u and -o
like so BUILD_FLAGS: -u 'https://tony-spegel.com' -o 'dist'
closing for the lack of follow up