From 267de5760755663f0e7c5f7abe6bf0399ae2dffc Mon Sep 17 00:00:00 2001 From: kingbri Date: Thu, 10 Sep 2020 11:23:24 -0400 Subject: [PATCH] Add a server workflow On a release create event, build and push to RoyalGuard's main server. Signed-off-by: kingbri --- .github/workflows/server.yml | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/server.yml diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml new file mode 100644 index 0000000..b00e4cd --- /dev/null +++ b/.github/workflows/server.yml @@ -0,0 +1,53 @@ +name: Push and Restart bot + +on: + release: + types: + - created + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: Cache Deps + uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - name: Build + run: cargo build --release --verbose + - name: Run tests + run: cargo test --verbose + - name: Remove old binary + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + port: ${{ secrets.PORT }} + script: rm -rf ~/RoyalGuard/royalguard + - name: Push new binary + uses: appleboy/scp-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + port: ${{ secrets.PORT }} + source: target/release/royalguard + target: ~/RoyalGuard + strip_components: 2 + - name: Restart CourtJester + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} + port: ${{ secrets.PORT }} + script: sudo systemctl restart royalguard.service \ No newline at end of file