[使用GitHub Actions从远程自动拉动

问题描述 投票:0回答:1

我在GitHub上有一个私有存储库,我的目标是只要有新提交,我们都会在VPS上更新存储库。

What I am currently doing is using an SSH action to log on to the server, locate the repository, and pull from the origin

问题是存储库是私有的,需要身份验证。我尝试在全局git config中设置我的用户名和密码,但是即使这样做,仍然需要验证。

git ubuntu github command-line-interface
1个回答
0
投票

独自找出解决方案。我正在做的各种事情的问题如下。我正在尝试按照git pull https://${{ secrets.TOKEN }}@github.com/repo

的方式进行操作

解决方案是将整个命令git pull https://[email protected]/repo设置为秘密,然后通过SSH运行脚本:${{ secrets.SCRIPT }}

我在此结束时的动作:

name: Remote SSH
on: [push]
jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
    - name: executing remote ssh commands using password
      uses: appleboy/ssh-action@master
      with:
        host: ${{ secrets.IP }}
        username: ${{ secrets.USER }}
        password: ${{ secrets.PRIVATE_KEY }}
        port: ${{ secrets.PORT }}
        script: |
          cd Repository
          ${{ secrets.SCRIPT}}
          pm2 restart 0
© www.soinside.com 2019 - 2024. All rights reserved.