name: Deploy to VPS on: push: branches: - main jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 # Build - name: Pull latest changes on VPS uses: appleboy/ssh-action@master with: host: ${{ secrets.VPS_HOST }} USERNAME: ${{ secrets.VPS_DEPLOY_USER }} PORT: ${{ secrets.VPS_SSH_PORT }} KEY: ${{ secrets.VPS_SSHKEY }} script: cd ${{ secrets.VPS_PROJECT_PATH }} && git fetch && git checkout main && git pull - name: Build uses: appleboy/ssh-action@master with: host: ${{ secrets.VPS_HOST }} USERNAME: ${{ secrets.VPS_DEPLOY_USER }} PORT: ${{ secrets.VPS_SSH_PORT }} KEY: ${{ secrets.VPS_SSHKEY }} script: cd ${{ secrets.VPS_PROJECT_PATH }} && docker-compose run mkdocswiki build # Deploy - name: Deploy new image and cleanup uses: appleboy/ssh-action@master with: host: ${{ secrets.VPS_HOST }} USERNAME: ${{ secrets.VPS_DEPLOY_USER }} PORT: ${{ secrets.VPS_SSH_PORT }} KEY: ${{ secrets.VPS_SSHKEY }} script: docker-compose -f ~/docker-compose.yml up -d && docker image prune -af