.github/workflows/deploy.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 name: Deploy to Server on: push: branches: - main jobs: base: runs-on: ubuntu-22.04 concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true steps: - uses: actions/checkout@v3 - uses: cross-the-world/ssh-pipeline@master env: SCRIPT: | #!/bin/sh # 变量 GITHUB_OWNER="hongfs" GITHUB_REPO="仓库名称" GITHUB_TOKEN="github_pat_11AFSLBeYl9QX8Mjn1LpIeWXXLFJwCCH5I466QbDI1JVd6" BASEPATH="/home/wwwroot/" BASENAME="web-api" cd $BASEPATH if [ ! -d "$BASEPATH$BASENAME" ]; then git clone https://$GITHUB_OWNER:$GITHUB_TOKEN@github.com/$GITHUB_OWNER/$GITHUB_REPO.git $BASENAME fi cd $BASENAME git reset --hard HEAD git pull with: host: test.hongfs.cn user: root pass: ${{ secrets.PASSWORD }} port: 22 connect_timeout: 3000s script: | echo '$SCRIPT' | sh