From 6d10daa33fa6b7d982d506e303117e048922a8f5 Mon Sep 17 00:00:00 2001 From: 1Step621 Date: Tue, 21 Jan 2025 17:10:45 +0900 Subject: [PATCH] chore: deploy with github actions --- .github/workflows/deploy.yaml | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..7201266 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,49 @@ +name: deploy +on: workflow_dispatch + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Cache dependencies + uses: Swatinem/rust-cache@v2 + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + + - name: Install cross + uses: taiki-e/setup-cross-toolchain-action@v1 + with: + target: x86_64-unknown-linux-musl + + - name: Build + run: cargo build --release + + - name: Send to server + uses: appleboy/scp-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.PRIVATE_KEY }} + passphrase: ${{ secrets.PASSPHRASE }} + port: ${{ secrets.PORT }} + source: ./target/x86_64-unknown-linux-musl/release/task-bot-rs + target: ~/task-bot-rs + overwrite: true + + - name: Restart service + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.PRIVATE_KEY }} + passphrase: ${{ secrets.PASSPHRASE }} + port: ${{ secrets.PORT }} + script: | + cd task-bot-rs || exit + ./kill.sh + ./run.sh + ps ux | grep bot | grep -v grep | grep -v bash