我正在尝试使用GitHub Actions
自动部署Django
项目中的更改。重新启动服务时出现问题。上面写着:
Failed to restart gunicorn/nginx.service: Interactive authentication required.
我怎么才能让它工作?
这是deploy.yml
name: deploying changes
on:
push:
branches: [staging]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: deploying changes
uses: appleboy/ssh-action@master
with:
host: xxx.xx.xx.xxx
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script: |
cd proj/
sh deploy.sh
deploy.sh
# Cd into the required directory
cd proj/
# Pull the changes
git pull
python manage.py migrate
# Collectstatic
python manage.py collectstatic --noinput
# Restart gunicorn and reload nginx
service gunicorn restart
service nginx restart
1条答案
按热度按时间2jcobegt1#
我通过在服务之前添加
sudo
来实现这一点: