nginx deploy #91
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Auto Deploy on Push | |
| on: | |
| push: | |
| branches: | |
| - stock # 监听 main 分支推送 | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| environment: AliyunECS # 如果你使用了环境 Secrets,必须指定 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| # - name: Copy folder content recursively to remote | |
| # uses: garygrossgarten/github-action-scp@release | |
| # with: | |
| # local: './' | |
| # remote: '/data/MyCode' | |
| # host: ${{ secrets.SSH_HOST }} | |
| # username: ${{ secrets.SSH_USER }} | |
| # privateKey: ${{ secrets.SSH_PRIVATE_KEY }} | |
| # port: ${{ secrets.SSH_PORT || 22 }} # 如未设置,默认 22 | |
| # rmRemote: true | |
| # dotfiles: 'true' | |
| # recursive: true | |
| - name: Deploy via SSH | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USER }} | |
| key: ${{ secrets.SSH_PRIVATE_KEY }} | |
| port: ${{ secrets.SSH_PORT || 22 }} # 如未设置,默认 22 | |
| script: | | |
| cd /data | |
| if [ -d "stock" ]; then | |
| cd MyCode | |
| git checkout . | |
| git pull -r | |
| else | |
| git clone -b stock git@github.com:wanggx/stock.git stock | |
| fi | |
| cd /data/stock # 替换为你服务器上项目的路径 | |
| ls -l | |
| cd bin | |
| ls -l | |
| chmod +x stop.sh start.sh | |
| ./stop.sh | |
| ./start.sh |