Fluent integration #130
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: MSTest | |
on: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
dotnet-build: | |
name: Dotnet Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: dotnet restore src/Egroo.Server/Egroo.Server.csproj | |
- name: Build | |
run: dotnet build --no-restore src/Egroo.Server/Egroo.Server.csproj | |
- name: Test | |
run: dotnet test --no-build --verbosity normal src/Egroo.Server/Egroo.Server.csproj | |
docker-build: | |
name: Docker Build | |
needs: dotnet-build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Create appsettings | |
run: | | |
echo '{ | |
"Logging": { | |
"LogLevel": { | |
"Default": "Information", | |
"Microsoft.AspNetCore": "Warning" | |
} | |
}, | |
"AllowedHosts": "*", | |
"ConnectionStrings": { | |
"DefaultConnection": "Server='${{ secrets.REMOTE_HOST }}';Port=5432;User Id=postgres;Password='${{ secrets.REMOTE_PASSWORD }}';Database=\"egroo-dev-test\";" | |
}, | |
"Api": { | |
"AllowedOrigins": [ "https://jihadkhawaja.com/", "https://dev-api-chat.jihadkhawaja.com/" ] | |
}, | |
"Secrets": { | |
"Jwt": "${{ secrets.JWT_UAT }}" | |
} | |
}' > src/Egroo.Server/appsettings.json | |
- name: build docker image | |
run: docker build -t jihadkhawaja/mobilechat-server:latest -f src/Egroo.Server/Dockerfile . | |
- name: save docker image | |
run: | | |
docker save -o mobilechat-server.tar jihadkhawaja/mobilechat-server | |
- name: copy tar via ssh | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.REMOTE_HOST }} | |
username: ${{ secrets.REMOTE_USER }} | |
key: ${{ secrets.KEY }} | |
port: 22 | |
source: "mobilechat-server.tar" | |
target: "/home/ubuntu/images" | |
- name: executing remote ssh commands | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.REMOTE_HOST }} | |
username: ${{ secrets.REMOTE_USER }} | |
key: ${{ secrets.KEY }} | |
script: | | |
docker load -i /home/ubuntu/images/mobilechat-server.tar | |
rm /home/ubuntu/images/mobilechat-server.tar | |
docker kill mobilechat-server | |
docker system prune -f | |
docker run --name mobilechat-server -p 43222:8080 --restart always -d jihadkhawaja/mobilechat-server:latest | |
uni-test: | |
runs-on: ubuntu-latest | |
needs: docker-build | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Restore dependencies | |
run: dotnet restore src/Egroo.Server.Test/Egroo.Server.Test.csproj | |
- name: Build | |
run: dotnet build --configuration Release src/Egroo.Server.Test/Egroo.Server.Test.csproj | |
- name: Test | |
run: dotnet test --logger trx --results-directory TestResults --configuration Release src/Egroo.Server.Test/Egroo.Server.Test.csproj | |
continue-on-error: false | |
- name: Upload Test Results | |
uses: actions/upload-artifact@v2 | |
with: | |
name: Test Results | |
path: TestResults/*.trx | |
docker-stop: | |
name: Docker Stop | |
needs: uni-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: executing remote ssh commands | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.REMOTE_HOST }} | |
username: ${{ secrets.REMOTE_USER }} | |
key: ${{ secrets.KEY }} | |
script: | | |
docker kill mobilechat-server | |
docker system prune -f | |
database-drop: | |
name: Database drop | |
needs: docker-stop | |
runs-on: ubuntu-latest | |
steps: | |
- name: executing remote ssh commands | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.REMOTE_HOST }} | |
username: ${{ secrets.REMOTE_USER }} | |
key: ${{ secrets.KEY }} | |
script: | | |
docker exec postgres psql -U postgres -c "drop database \"egroo-dev-test\" WITH ( FORCE );" |