This should be it #4
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: ReplayBrowser.sln | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
- name: Build Client | |
run: dotnet build ./Client/Client.csproj | |
- name: Build Server | |
run: dotnet build ./Server/Server.csproj | |
- 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='deploy' ./ ./deploy | |
echo '${{ secrets.SERVER_APPSETTINGS }}' > ./deploy/Server/appsettings.Secret.json | |
echo '${{ secrets.CLIENT_APPSETTINGS }}' > ./deploy/Client/appsettings.json | |
- name: Upload files to server | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SERVER_IP }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
source: "./deploy/*" | |
target: /home/${{ secrets.SERVER_USERNAME }}/ReplayBrowser | |
- name: End services | |
run: | | |
ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }} "sudo systemctl stop replaybrowser.client.service" | |
ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }} "sudo systemctl stop replaybrowser.server.service" | |
- name: Run EF Core Migrations | |
run: | | |
ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }} "cd /home/${{ secrets.SERVER_USERNAME }}/ReplayBrowser/Server && dotnet ef database update" | |
- name: Start services | |
run: | | |
ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }} "sudo systemctl start replaybrowser.client.service" | |
ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_IP }} "sudo systemctl start replaybrowser.server.service" |