无法通过 GitHub Actions 中的 lftp 镜像文件。

huangapple go评论104阅读模式
英文:

Can't mirror files via lftp in github actions

问题

我目前正在开发一个GitHub Action,用于通过SFTP将更改的文件上传到服务器。为此,我在一个Docker容器中设置了一个Shell脚本。一切都运行正常,直到上传部分,它能够连接到服务器,但在lftp命令上出现错误,错误信息是mirror: Access failed: /home/username_here/test: No such file or directory。Shell文件中的lftp命令是lftp -d -c "set ftp:ssl-allow no; open -u $SFTP_USER,placeholder -e 'mirror -R --delete --only-newer --exclude-glob .git/ --exclude-glob .github/ -P1 --parallel=10 -x changed_files.txt $REMOTE_PATH' $SFTP_HOST"。SFTP_USER设置为用户名,$REMOTE_PATH设置为'/home/username/test/',SFTP_HOST设置为目标服务器的IP地址。所有这些都是通过workflow.yml文件设置的。

我尝试过将路径设置为不同的内容,但似乎它试图将文件移动到runner的目录中?当我将其更改为相对目录时,它显示错误mirror: Access failed: /github/workspace/test: No such file or directory

英文:

I am currently working on a GitHub Action to upload changed files onto a server via sftp.
For this I have set up a shell script in a docker container. Everything up until the upload works, it connects to the server but errors out on the lftp command, the error beeing mirror: Access failed: /home/username_here/test: No such file or directory.
The lftp command from the shell file is lftp -d -c "set ftp:ssl-allow no; open -u $SFTP_USER,placeholder -e 'mirror -R --delete --only-newer --exclude-glob .git/ --exclude-glob .github/ -P1 --parallel=10 -x changed_files.txt $REMOTE_PATH' $SFTP_HOST". SFTP_USER is set to the username, $REMOTE_PATH is set to '/home/username/test/' and SFTP_HOST is set to the ip of the target server. These are all set via the workflow.yml file.

I have tried setting the path to different stuff, but it seems that it tries to move stuff into the directory of the runner? When I change it to a relativ directory, it show the error mirror: Access failed: /github/workspace/test: No such file or directory

答案1

得分: 1

我已经让它可以工作了。我现在正在使用lftp命令切换到目标目录,所以现在的命令是 lftp -d -c "set ftp:ssl-allow no; open -u $SFTP_USER,placeholder -e 'cd $REMOTE_PATH; mirror -R --delete --only-newer --exclude-glob .git/ --exclude-glob .github/ -P1 --parallel=10 -x changed_files.txt .'" $SFTP_HOST

英文:

So I have gotten it to work. I am now changing directory into the target directory via the lftp command, so the command now is lftp -d -c "set ftp:ssl-allow no; open -u $SFTP_USER,placeholder -e 'cd $REMOTE_PATH; mirror -R --delete --only-newer --exclude-glob .git/ --exclude-glob .github/ -P1 --parallel=10 -x changed_files.txt .' $SFTP_HOST"

huangapple
  • 本文由 发表于 2023年6月4日 23:54:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76401239.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定