From 7701f17f45764fd1139057e8466d5cab3695427b Mon Sep 17 00:00:00 2001 From: Vladimir Samoilenko Date: Tue, 10 Sep 2019 05:05:34 +0200 Subject: [PATCH] add worflow --- .github/workflows/main.yml | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..2c24a295 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,55 @@ +name: ASP.NET Core CI + +on: + push: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.0.100-preview9-014004 + - name: Build with dotnet + run: | + cd src + dotnet build --configuration Release + - name: Publish MatBlazor.Demo.ServerApp + run: | + cd src + dotnet publish MatBlazor.Demo.ServerApp -o ./publish/MatBlazor.Demo.ServerApp + - name: Deploy MatBlazor.Demo.ServerApp + env: + PRIVATE_KEY: ${{ secrets.ssh_key }} + HOST: srv4.samprof.com + USER: root + run: | + cd src + set -e + + SSH_PATH="$HOME/.ssh" + + mkdir -p "$SSH_PATH" + touch "$SSH_PATH/known_hosts" + + echo "$PRIVATE_KEY" > "$SSH_PATH/deploy_key" + + chmod 700 "$SSH_PATH" + chmod 600 "$SSH_PATH/known_hosts" + chmod 600 "$SSH_PATH/deploy_key" + + eval $(ssh-agent) + ssh-add "$SSH_PATH/deploy_key" + + ssh-keyscan -t rsa $HOST >> "$SSH_PATH/known_hosts" + + ssh -o StrictHostKeyChecking=no -A -tt -p ${PORT:-22} $USER@$HOST "systemctl stop www.matblazor.com.service" + scp -r ./publish/MatBlazor.Demo.ServerApp/* $USER@$HOST:/var/host/www.matblazor.com + ssh -o StrictHostKeyChecking=no -A -tt -p ${PORT:-22} $USER@$HOST "systemctl stop www.matblazor.com.service" + + ssh -o StrictHostKeyChecking=no -A -tt -p ${PORT:-22} $USER@$HOST "systemctl start www.matblazor.com.service" +