我正在尝试创建一个操作,在每次推送时将更改推送到 pantheon,这样我们就可以使用 GitHub 拥有更高级的工作流程,同时保持在 pantheon 上创建的开发站点的便利性。我设置了3个秘密
经过一番谷歌搜索后想出了这个动作:
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。
完成结帐步骤后,您需要添加此步骤:
- uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.PANTHEON_SSH_KEY }}
config: ${{ secrets.SSH_CONFIG }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
用您自己的秘密变量替换秘密