我有一个deployment.yml
的工作流,它看起来像这样:
name: Deployment
on:
push:
branches: [ production ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1.1.0
with:
version: 10.x
- name: Install dependencies
run: |
composer install -o
yarn
- name: Build
run: yarn build:production
- name: Sync
env:
dest: 'user@server:/var/www/html/wp-content/themes/theme-name'
run: |
echo "${{secrets.DEPLOY_KEY}}" > deploy_key
chmod 600 ./deploy_key
rsync -chav --delete \
-e 'ssh -i ./deploy_key -o StrictHostKeyChecking=no' \
--exclude /deploy_key \
--exclude /.git/ \
--exclude /.github/ \
--exclude /node_modules/ \
./ ${{env.dest}}
执行此操作时,我在Sync
步骤收到一个错误,并显示以下错误。
Run echo "***" > deploy_key
echo "***" > deploy_key
chmod 600 ./deploy_key
rsync -chav --delete \
-e 'ssh -i ./deploy_key -o StrictHostKeyChecking=no' \
--exclude /deploy_key \
--exclude /.git/ \
--exclude /.github/ \
--exclude /node_modules/ \
./ root@111.11.111.111:/var/www/html/wp-content/themes/theme-name
shell: /bin/bash -e {0}
env:
dest: root@159.89.165.152:/var/www/html/wp-content/themes/theme-name
Warning: Permanently added '111.11.111.111' (ECDSA) to the list of known hosts.
Load key "./deploy_key": invalid format
Permission denied, please try again.
Permission denied, please try again.
root@111.11.111.111: Permission denied (publickey,password).
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(235) [sender=3.1.2]
##[error]Process completed with exit code 255.
这是设置了SSH密钥并添加到授权密钥的Digital Ocean小滴。 也在我里面存储库设置 我将它们添加到:
我的设置错误吗?
答案 0 :(得分:3)
我发现我的代码未运行的原因是因为我一直在秘密DEPLOY_KEY
中添加公钥。
您必须添加private key
作为密码。
另外,您也不要忘记将您的公开对象添加到authorized_keys
列表中,否则您的操作将失败。
这是我使用的最终deployment.yml
文件。
name: Deployment
on:
push:
branches: [ production ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1.1.0
with:
version: 12.x
- name: Install dependencies
run: |
composer install -o
yarn
- name: Build
run: yarn build
- name: Sync
env:
dest: 'root@111.11.111.111:/var/www/html/wp-content/themes/theme-name' // Change here
run: |
echo "${{secrets.DEPLOY_KEY}}" > deploy_key
chmod 600 ./deploy_key
rsync -chav --delete \
-e 'ssh -i ./deploy_key -o StrictHostKeyChecking=no' \
--exclude /deploy_key \
--exclude /.git/ \
--exclude /.github/ \
--exclude /node_modules/ \
./ ${{env.dest}}
此特定部署用于sage(一种WordPress入门主题),并部署在具有openlitespeed服务器的数字海洋小滴中。
我写了a post,解释了圣人根的完整部署过程。