From b69444b81a476cdbfd83c4573a805007ed56bc1b Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Sat, 27 Jun 2020 21:05:32 -0400 Subject: [PATCH] Create sample workflows --- .github/workflows/build_test.yml | 49 ++++++++++++++++++++++++++++++++ .github/workflows/deploy.yml | 41 ++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 .github/workflows/build_test.yml create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml new file mode 100644 index 0000000..3e9e89e --- /dev/null +++ b/.github/workflows/build_test.yml @@ -0,0 +1,49 @@ +name: Build and Test + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +env: + CARGO_TERM_COLOR: always + +jobs: + format_check: + name: Format check + runs_on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: rustfmt + - name: Run rustfmt + run: cargo fmt -- --check + check_and_test: + name: Lint and Test + runs_on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - name: Check + run: cargo check --verbose + - name: Test + run: cargo test --verbose diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..81f3abc --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,41 @@ +name: Deploy + +on: + push: + branches: [ master ] + +jobs: + deploy: + name: Build and Deploy + runs_on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - name: Build release + run: cargo build --release + - name: Upload binary + uses: appleboy/scp-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.SSH_KEY }} + port: ${{ secrets.PORT }} + source: "target/release/youmubot" + target: "youmubot/youmubot" + - name: Restart youmubot + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.SSH_KEY }} + port: ${{ secrets.PORT }} + script: systemctl --user restart youmubot