-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for serving GitHub pages from non root directory #81
base: main
Are you sure you want to change the base?
Conversation
action.yml
Outdated
|
||
targetdir="$umbrella/pr-$pr" | ||
echo "targetdir=$targetdir" >> $GITHUB_ENV | ||
echo "pagespath=${targetdir/"$pagesbase"/}" >> $GITHUB_ENV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If $pagesbase
is e.g. docs/
and $targetdir
is e.g. project-docs/pr-preview/pr-1
, this would result in project-pr-preview/pr-1
which is not the intended result. (Would $pagesbase
containing a slash character interfere with the replacement? My bash-fu isn't strong enough to instinctively know)
I think it's reasonable to assume that situation won't happen, because if the user is specifying a base dir you'd expect their path to start with that base dir. But it would also be nice to permit formats like docs
, docs/
, ./docs/
, maybe even /docs/
. I figure there must be some robust way to remove a path section in bash other than string substitution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated it to make use of regex instead, will only replace if at the start of the string now.
Also made the end /
optional to close off pages-base-dir
.
umbrella-dir: ./docs/preview-docs
pages-base-dir: ./docs
# pagespath: preview-docs/pr-123
umbrella-dir: /docs/preview-docs
pages-base-dir: /docs
# pagespath: preview-docs/pr-123
umbrella-dir: docs/preview-docs
pages-base-dir: docs
# pagespath: preview-docs/pr-123
umbrella-dir: docs/preview-docs
pages-base-dir: docs/
# pagespath: preview-docs/pr-123
This does sort of depend on the user typing the beginning the same for umbrella-dir
and pages-base-dir
(both start with ./path
, /path
or path
)
But I think majority of the time this would happen naturally anyway, but added it to the documentation as well.
Description:
Will allow for generating a URL to the correct preview when serving GitHub pages from any directory other than the root directory.
Adds a new optional param which will be removed from
umbrella-dir
to determine the correct path to the preview.Related issues:
closes #42
Notes:
Let me know if you think there might be a better approach to this.