shell GitHub操作-无法重新启动XXX.service:需要交互式身份验证

dfty9e19  于 2023-10-23  发布在  Shell
关注(0)|答案(1)|浏览(105)

我正在尝试使用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
2jcobegt

2jcobegt1#

我通过在服务之前添加sudo来实现这一点:

sudo service gunicorn restart
# OR sudo systemctl restart php8.1-fpm.service

相关问题