Closed MatthijsMud closed 4 years ago
Hi @MatthijsMud! Thanks for opening an issue. I believe you can still pass the extra set of dashes as part of the gatsby-args
input. For example:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: enriikke/gatsby-gh-pages-action@v2
with:
access-token: ${{ secrets.ACCESS_TOKEN }}
deploy-branch: gh-pages
gatsby-args: -- --prefix-paths
I think it's still a great idea to highlight this in the documentation. I'll be happy to accept a PR for that if you have some time. Otherwise I can try to update it sometime this week.
Would you mind first confirming that works for you? 😃
Tested the suggested solution, but it unfortunately does not seem to work; Gatsby acts as though the prefix-paths option is not provided.
Output in the console of GitHub
Finished installing dependencies. Ready to build your Gatsby site! Building with: npm run build -- --prefix-paths npm run build -- --prefix-paths > gatsby-starter-default@0.1.0 build /home/runner/work/gatsby-gh-pages-action-test/gatsby-gh-pages-action-test > gatsby build
Output in the console on my computer
$ npm run build -- --prefix-paths > gatsby-starter-default@0.1.0 build /home/matthijs/gatsby-gh-pages-action-test > gatsby build "--prefix-paths"
My suspicion is that this action provides the arguments as a single string (["-- --prefix-paths"]
), where NPM expects it to be two separate ones (`["--", "--prefix-paths"]"), but this is just a wild guess.
Adding the --prefix-paths
option to the build command in package.json
does the trick. Note that the extra set of dashes is not required in this case ("build": "gatsby build --prefix-paths"
). I'm not sure how opposed users would be to this option.
Other than that, the documentation could be used to recommend the usage of Yarn instead, is it does seem to function correctly there.
Thank you @MatthijsMud. You are correct that this is passing "-- --prefix-paths"
as a single param. I think fixing this should be pretty straight forward though. I'm going to try to get to it this weekend but feel free to open a PR if you've got some time. 😃
While using this action to create a test build on a
gh-pages
branch using Gatsby's default starter, I ran into an issue where the site was not generated correctly; none of the links included the path prefix. This is apparently because the arguments are not forward to the NPM build command, so Gatsby did not know that it should prefix any paths.NPM requires an extra set of dashes to forward any parameters to a given command, according to this StackOverflow answer. So depending on the package manager, the build command should look something like the following.