Create deploy-to-ancikri.yml
This commit is contained in:
@@ -0,0 +1,65 @@
|
|||||||
|
name: Deploy to Ancikri
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- develop
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Build the project
|
||||||
|
run: cargo build --release
|
||||||
|
|
||||||
|
- name: Stop service on VPS before upload
|
||||||
|
uses: appleboy/ssh-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.VPS_ANCIKRI_IP }}
|
||||||
|
username: ${{ secrets.VPS_ANCIKRI_USER }}
|
||||||
|
key: ${{ secrets.VPS_ANCIKRI_SSH_KEY }}
|
||||||
|
port: ${{ secrets.VPS_ANCIKRI_PORT }}
|
||||||
|
script: |
|
||||||
|
set -e
|
||||||
|
echo "Stopping the service before uploading the binary"
|
||||||
|
sudo systemctl stop imphnen-backend-service
|
||||||
|
|
||||||
|
- name: Upload artifact to VPS
|
||||||
|
uses: appleboy/scp-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.VPS_ANCIKRI_IP }}
|
||||||
|
username: ${{ secrets.VPS_ANCIKRI_USER }}
|
||||||
|
key: ${{ secrets.VPS_ANCIKRI_SSH_KEY }}
|
||||||
|
port: ${{ secrets.VPS_ANCIKRI_PORT }}
|
||||||
|
source: ./target/release/*
|
||||||
|
target: /opt/imphnen-backend-service/imphnen-backend-service
|
||||||
|
rm: true
|
||||||
|
overwrite: true
|
||||||
|
|
||||||
|
- name: Deploy to server
|
||||||
|
uses: appleboy/ssh-action@v0.1.7
|
||||||
|
with:
|
||||||
|
host: ${{ secrets.VPS_ANCIKRI_IP }}
|
||||||
|
username: ${{ secrets.VPS_ANCIKRI_USER }}
|
||||||
|
key: ${{ secrets.VPS_ANCIKRI_SSH_KEY }}
|
||||||
|
port: ${{ secrets.VPS_ANCIKRI_PORT }}
|
||||||
|
script: |
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "Restarting the service"
|
||||||
|
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
|
||||||
|
sudo systemctl restart imphnen-backend-service
|
||||||
|
|
||||||
|
echo "Deployment completed successfully"
|
||||||
Reference in New Issue
Block a user