emacs-ssh-deploy icon indicating copy to clipboard operation
emacs-ssh-deploy copied to clipboard

Deploying a predefined set of files

Open UndeadKernel opened this issue 5 years ago • 2 comments

I was wondering if it is possible to upload a set of files every time I call ssh-deploy-upload-handler instead of only the currently opened file. Imagine this setting: I have an org file with some code blocks. These blocks are tangled into their own scripts. When I upload the "main" org file, I also want to upload the associated tangled files.

What is the "canonical" way to copy a whole project (e.g., a git repo) onto a remote location while running an ssh-deploy-* command within a open file of the project?

UndeadKernel avatar May 05 '20 09:05 UndeadKernel

Yeah I would define a upload script that uploads the specific files, I’ll give an example when I’m at my computer

cjohansson avatar May 10 '20 05:05 cjohansson

Here is an example, I haven't tested it, please let me know if it doesn't work.

.dir-locals.el contents:

((nil . (
  (ssh-deploy-root-local . "/Users/username/Web/MySite/")
  (ssh-deploy-root-remote . "/ssh:[email protected]|sudo:[email protected]:/var/www/MySite/")
  (ssh-deploy-script .
                   (lambda()
                     (let ((buffer-file-name "myFirstFile.txt"))
                       (ssh-deploy-upload-handler))
                     (let ((buffer-file-name "mySecondFile.txt"))
                       (ssh-deploy-upload-handler))))
)))

When you run the (ssh-deploy-run-deploy-script-handler) the script should upload both files.

cjohansson avatar May 10 '20 18:05 cjohansson

Sorry for being late to the party :D

The solution you propose works when I manually call ssh-deploy-run-deploy-script-handler. Is it possible to configure ssh-deploy to call the script automatically when I save a file? My .dir-locals.el file looks like the following and the script is not run automatically on save:

((nil . ((ssh-deploy-root-local . "/home/user/app/")
         (ssh-deploy-root-remote . "/ssh:user:/home/user/app/")
         (ssh-deploy-on-explicit-save . 1)
         (ssh-deploy-script .  (lambda()
                                 (let ((buffer-file-name "client"))
                                   (ssh-deploy-upload-handler))
                                 (let ((buffer-file-name "server"))
                                   (ssh-deploy-upload-handler)))))))

UndeadKernel avatar Feb 20 '23 12:02 UndeadKernel

I see, I could add a setting for that if you want, like ssh-deploy-run-script-on-save or something?

cjohansson avatar Feb 21 '23 21:02 cjohansson

Such a setting/feature would be more than welcome @cjohansson.

UndeadKernel avatar Feb 22 '23 16:02 UndeadKernel

This should be fixed in commit 0e93dd6044a7f3fcd2938da39522719d7c779790

cjohansson avatar Jul 01 '23 09:07 cjohansson