Open Tbhesswebber opened 1 year ago
Deploying documentation to docs/
on the main branch vs deploying it to the root directory on the gh-pages
branch are typically two different methods of isolating GitHub Pages deployments from the rest of the codebase. I'd say it's unusual to see a deployment to the docs/
directory on the gh-pages
branch - is this setup definitely intended?
A more traditional approach would be to copy docs/
on your feature branch to the root of the gh-pages
branch:
# Preview
- name: Deploy Preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: docs
preview-branch: gh-pages
umbrella-dir: pr-preview
action: auto
# Main deployment
- uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs
target-folder: .
branch: gh-pages
clean-exclude: pr-preview
That would probably be easiest and more in line with the 'standard' approach.
But assumptions and principle aside, if you really do need to deploy from docs/
on gh-pages
and you're using the root dir on gh-pages
for something else, then you're right - there's currently no way to do that. The variable used for the deployment target dir is the same as the one used to construct the URL:
The long-term solution to this would be to add a parameter that indicates what directory Pages is being served from in that repo, as you originally suggested.
We can definitely get around this by changing configurations in GH, but I think this is still a valuable feature to add for anyone who doesn't have easy access to the repo settings or a person with repo admin access.
+1 for this, even if it was just a separate input which would replace the partial string of umbrella-dir.
umbrella-dir: 'docs/preview'
pages-base: 'docs/'
then on the output just replace any instance of pages-base
in umbrella-dir
before sending the url.
Our Github Pages configuration is set up to serve from a subdirectory and there is currently no documented way to address this with pr-preview-action.
Example:
Preview Deployment Action
Deployment Action
With the above configurations, we end up with everything correctly being saved to the
docs
directory. The generated preview link is/docs/pr-preview/pr-xx
. I can delete the/docs
path part and see the preview just fine, but the generated link shows a totally valid 404 because we are serving directly from thedocs
directory that things are being saved to rather than serving from the root directory.