在 github actions main.yml 中的 run 中使用 git pull
我正在尝试更新运行我公司某些站点的某些非生产版本的本地服务器,以便在主存储库合并拉取请求时进行更新。但是,当操作到达 git pul ... 行时,操作就会停止。日志不提供任何信息,该过程似乎停止了。我可以在命令提示符中运行相同的命令。任何建议表示赞赏。
main.yml
name: CI
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
deployment:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Test
shell: cmd
run: actions.cmd
actions.cmd
cd path\to\stuff
git pull remoteName master
更新,遇到了一些奇怪的缓存问题,但能够清理一些并收到一些错误消息:
nothing to commit, working tree clean
fatal: 'github' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
success
Error: Process completed with exit code 1.
github 是远程的名称。同样,我可以正常运行这些脚本,但工作流程可能需要一些额外的身份验证?
I am trying to update a local server running some non-production versions of some of my company's sites to update whenever the main repository merges a pull request. However, the action stalls out when the action hits the git pul ...
line. The logs do not provide any information, the process seemingly halts. I can run the same commands in the command prompt. Any advice is appreciated.
main.yml
name: CI
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
deployment:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Test
shell: cmd
run: actions.cmd
actions.cmd
cd path\to\stuff
git pull remoteName master
Update, ran into some weird caching issues but was able to clean up a little and got some error messages:
nothing to commit, working tree clean
fatal: 'github' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
success
Error: Process completed with exit code 1.
github is the name of the remote. Again, I can run these scripts normally, but maybe the workflow needs some additional authentication?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了将其传递下去并可能避免其他人的悲伤,我将对此进行更多说明。我遇到了类似的问题。我想在自托管运行器上运行 git pull 命令。
要在运行器上执行 pull 命令,您需要在命令中提供身份验证。您可以使用个人访问令牌进行身份验证。使用令牌身份验证,命令如下所示:
git pull https://@github.com/
我将整个命令包装在一个名为 PULL 的秘密中。
我的最终工作流程如下所示:
To pay it forward and potentially save someone else some grief, I'll shed a little more light on this. I faced a similar issue. I wanted to run a
git pull
command on a self-hosted runner.To execute the pull command on the runner, you need to provide authentication in your command. You can use a Personal Access Token to authenticate. With token authentication, the command looks like:
git pull https://<token>@github.com/<repo_url.git>
I wrapped up the whole command in a secret I named PULL.
My final workflow looks like this:
原来这是一个身份验证问题。不幸的是,在运行器上执行操作时进行调试(即使是自托管)非常令人沮丧。如果有人知道更好的方法,请随时更新我。
基本上,运行程序没有与托管运行程序的服务器相同的访问权限,因此我只需向脚本添加一些身份验证步骤。我认为会这样,因为我已经将服务器配置为手动成功运行相同的命令,但这似乎确实是一个很好的安全措施。
Turns out it was an authentication issue. Unfortunately, debugging when actions are being executed on the runner (even when self-hosted) is very frustrating. If anyone knows a better way please feel free to update me.
Basically the runner did not have the same access rights as the server that was hosting the runner, so I just had to add some authentication steps to the scripts. I thought it would since I already configured the server to successfully run the same commands manually, but this does seem like a good security measure.