1

我正在尝试使用 github 操作部署 PHP 项目

目标服务器上的连接有效,但是当部署者尝试克隆存储库时,我陷入了困境。

为了访问服务器,我在 github 密钥中存储了一个私有 ssh 密钥,并且我尝试使用相同的 ssh 密钥来访问 github 存储库(该密钥已添加到存储库的部署密钥中)。

这里失败的命令:

cd {releasePath} && (/usr/bin/git clone -b "develop" --recursive  git@github.com:arnaudschaeffer/myprivaterepo.git {releasePath} /releases/3 2>&1)
 Command failed with exit code 1: bin/dep deploy staging -vvv

Deployer 在我的本地环境中工作。我可以使用我的个人 SSH 密钥和我拥有的密钥来连接到目标服务器。

这是我的 github yml 文件:

# This is a basic workflow to help you get started with Actions
name: Deploy develop

# Controls when the action will run.
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ develop ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  deploy:
    name: Deploy to develop
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          ref: 'develop'
          ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
          persist-credentials: true

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: 7.4

      - name: Configure SSH
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
          SSH_HOST: ${{ secrets.SSH_HOST }}
          SSH_USER: ${{ secrets.SSH_USER }}
          SSH_PORT: ${{ secrets.SSH_PORT }}
        run: |
          mkdir -p ~/.ssh/
          echo "$SSH_PRIVATE_KEY" > ~/.ssh/staging.key
          chmod 600 ~/.ssh/staging.key
          cat >>~/.ssh/config <<END
            Host github
              Hostname github.com
              IdentityFile ~/.ssh/staging.key
              IdentitiesOnly yes
            Host host_name
              HostName $SSH_HOST
              User $SSH_USER
              Port $SSH_PORT
              IdentityFile ~/.ssh/staging.key
              StrictHostKeyChecking no
          END

      - name: Set Up Deployer
        run: |
          curl -LO https://deployer.org/deployer.phar && mkdir bin && mv deployer.phar bin/dep && sudo chmod +x bin/dep

      # Add deploy key in GitHub account
      - name: Deploy
        uses: deployphp/action@master
        with:
          private-key: ${{ secrets.SSH_PRIVATE_KEY }}
          #Both target server and github known hosts
          known-hosts: ${{ secrets.KNOWN_HOSTS }}
          dep: deploy staging -vvv

是否有一些额外的步骤可以在部署器中克隆存储库?

预先感谢 !

4

0 回答 0