rstudio / actions

GitHub Actions for use with RStudio software.
MIT License
7 stars 11 forks source link

default vanity path (when not provided) is set to the absolute project path on GHA runner #13

Closed cderv closed 3 years ago

cderv commented 3 years ago

Seen here: https://github.com/cderv/deploy-bookdown-demo/runs/1533824331?check_suite_focus=true#step:9:5530 using this workflow https://github.com/cderv/deploy-bookdown-demo/actions/runs/414114799/workflow#L56 when only setting dir without :<vanity-path>

RSCONNECT-TS 1806: Deployer: updating vanity URL for app=14655 to path="/Users/runner/work/deploy-bookdown-demo/deploy-bookdown-demo/_book/"

This will then create a content on RSC with the app name: "usersrunnerworkdeploy-bookdown-demodeploy-bookdown-demo_book", and maybe this vanity url : https://beta.rstudioconnect.com/Users/runner/work/deploy-bookdown-demo/deploy-bookdown-demo/_book/ (does not work for me yet - see #12)

That is a bit too long !

@meatballhat told me it should use git rev-parse --show-toplevel. I can't find it in the action source code. Locally, this command will give me the full path : for example

git rev-parse --show-toplevel
/home/cderv/project/bookdown

So maye be this is the correct result behavior ?

Or is it a bug or just something to improve ?

I wouldn't use the default behavior if it would create such long name and vanity url by default! I would like to path the name directly (see #12), and if I have the right to do so the vanity path also.

By default, I think the app name should be a unique identifier. connectapi R 📦 use connectapi::create_random_name() to generate a random name, or `uuid::UUIDgenerate()``. However, it is used as title for the app in the main page, so maybe something more readable is better 🤷

meatballhat commented 3 years ago

I'm fairly sure that this is a problem with providing an absolute path as the dir value in the action. Should the default behavior be to always remove the common prefix of the git working directory from the dir value?

cderv commented 3 years ago

You're right, if I use a relative path for the dir argument the vanity url is this indeed the relative path. Just tried it. So using absolute path causes a long vanity path.

I don't know what the default behavior should be - I guess I was expecting the default vanity url would be built using relative path from the git repo yes.

I wonder what happens if I want to deploy from the current working directory directly (so using default dir: ".") - which I would do if I want to deploy the source. What is the default vanity url you are creating in that case ?

At usage, I think providing a :<identifier> after the directory is best practice. Not providing it is not a good idea as you would rely to luck for a content not already existing with a vanity path corresponding to your deployed directory. It would require I think to always take care to name my directory as the vanity path I want to have. But that is just a matter of practice.