Update deploy.yml #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: [ "master" ] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
env: | |
Solution_Name: SU.LorePage.sln | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
- name: Build | |
run: dotnet publish -c Release -r linux-x64 --self-contained true | |
- name: Install SSH Key | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Prepare files for deployment | |
run: | | |
mkdir deploy | |
rsync -av --exclude='bin' --exclude='obj' --exclude='.git' --exclude='.github' ./ deploy/ | |
- name: Upload to remote server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SERVER_IP }} | |
username: ${{ secrets.SSH_USER }} | |
key : ${{ secrets.SSH_PRIVATE_KEY }} | |
port: ${{ secrets.SSH_PORT }} | |
source: "deploy/*" | |
target: "/home/SS14/LorePage" | |
- name: Stop previous | |
run: | | |
ssh -o StrictHostKeyChecking=no -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }} "pkill -f LorePage || true" | |
- name: Start | |
run: | | |
ssh -o StrictHostKeyChecking=no -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }} "nohup dotnet run --project /home/${{ secrets.SSH_USER }}/LorePage/deploy/SU.LorePage/SU.LorePage.csproj > /home/${{ secrets.SSH_USER }}/LorePage/app.log 2>&1 &" |