GitHub 操作推送至万神殿

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

我正在尝试创建一个操作,在每次推送时将更改推送到 pantheon,这样我们就可以使用 GitHub 拥有更高级的工作流程,同时保持在 pantheon 上创建的开发站点的便利性。我设置了3个秘密

  1. SSH_KEY(私钥)
  2. 主机_IP
  3. PANTHEON_REPO(网址)

经过一番谷歌搜索后想出了这个动作:

name: Push to pantheon
on: [push,pull_request]
jobs:
  pusher:
    name: Push to pantheon
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install SSH key
        uses: shimataro/ssh-key-action@v2
        with:
          key: ${{ secrets.SSH_KEY }}
          known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
      - name: Adding Known Hosts
        run: ssh-keyscan -H ${{ secrets.HOST_IP }} >> ~/.ssh/known_hosts
      - name: Push changes
        run: |
          git remote add pantheon ${{ secrets.PANTHEON_REPO }}
          git config --local user.email "..."
          git config --local user.name "Github Action"
          git push pantheon ${GITHUB_REF##*/}

但是操作在

git remote add
处失败,并出现错误:

Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我专门为此创建了 ssh 密钥,并将公钥添加到了 pantheon。

github github-actions pantheon
1个回答
0
投票

完成结帐步骤后,您需要添加此步骤:

  - uses: shimataro/ssh-key-action@v2
    with:
      key: ${{ secrets.PANTHEON_SSH_KEY }}
      config: ${{ secrets.SSH_CONFIG }}
      known_hosts: ${{ secrets.KNOWN_HOSTS }}

用您自己的秘密变量替换秘密

© www.soinside.com 2019 - 2024. All rights reserved.