name: Deploy on: push: branches: [ master ] jobs: build: name: Build a Release Binary runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 id: cargo with: toolchain: stable components: clippy - uses: actions/cache@v2 with: path: | ~/.cargo/registry ~/.cargo/git target key: ${{ runner.os }}-rust-${{ steps.cargo.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}-release-build - name: Build release run: cargo build --release env: SQLX_OFFLINE: "true" - name: Upload compiled binary artifact uses: actions/upload-artifact@v1 with: name: youmubot-release path: target/release/youmubot deploy: name: Deploy to remote needs: build runs-on: ubuntu-latest steps: - name: Collect artifact uses: actions/download-artifact@v1 with: name: youmubot-release - name: Upload binary uses: appleboy/scp-action@master with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} key: ${{ secrets.SSH_KEY }} port: ${{ secrets.PORT }} source: youmubot-release/youmubot target: youmubot strip_components: 1 - name: Restart youmubot uses: appleboy/ssh-action@master with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} key: ${{ secrets.SSH_KEY }} port: ${{ secrets.PORT }} script: | chmod +x youmubot/youmubot systemctl --user restart youmubot