基于自动化配置需要,在使用Azure的时候发现可以快速进行自动化部署

以下采用VPC服务器、Python和Gunicorn进行自动化部署,配置文件如下:

name: Build and deploy Python app to Custom App

on:
    # 监听 push动作
    push:
        branches:
            - main
    # 手动触发
    workflow_dispatch:

jobs:
    deploy:
        runs-on: ubuntu-latest
        steps:
            -   name: 'Deploy to Custom App'
                uses: appleboy/ssh-action@master
                with:
                    host: ${{ secrets.DC_HOST }} # 公网 IP 或 域名
                    username: ${{ secrets.DC_USER }} # 登录名
                    password: ${{ secrets.DC_PASS }} # 密码
                    # 类似在服务端的终端-执行以下操作
                    script: |
                        cd /root/stock_py/
                        git pull
                        python3 -m venv venv
                        source venv/bin/activate
                        pip install -r requirements.txt
                        gunicorn -c gunicorn.conf.py wsgi:app


标签: none

添加新评论