diff --git a/.travis.yml b/.travis.yml index d94b57e..a213af0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -sudo: required +os: linux dist: bionic language: csharp mono: none @@ -18,6 +18,7 @@ stages: - test - publish - deploy + - database jobs: include: @@ -28,6 +29,7 @@ jobs: - sudo snap alias dotnet-sdk.dotnet dotnet script: - dotnet build + - stage: test name: dotnet-test before_script: @@ -35,6 +37,7 @@ jobs: - sudo apt-get update && sudo apt-get install curl -y script: - ./test.sh + - stage: publish name: docker-container-publish if: tag IS present @@ -45,6 +48,7 @@ jobs: - docker login -u ${REGISTRY_USER} -p ${REGISTRY_PASSWORD} ${REGISTRY} script: - ./publish-docker.sh + - stage: deploy name: deploy if: tag IS present @@ -52,3 +56,16 @@ jobs: - curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash script: - ./deploy-app.sh + + - stage: database + name: database migrations and updates + if: tag IS present + env: + global: + - DOTNET_ENVIRONMENT="Azure" + before_script: + - sudo snap alias dotnet-sdk.dotnet dotnet + script: + - ./execute-database-updates.sh + - rm -rf publish + - ./execute-database-migrations diff --git a/Covid19Api.sln b/Covid19Api.sln index 834360f..121f4fa 100644 --- a/Covid19Api.sln +++ b/Covid19Api.sln @@ -25,6 +25,8 @@ ProjectSection(SolutionItems) = preProject docker-compose.yml = docker-compose.yml Directory.Build.props = Directory.Build.props test.sh = test.sh + execute-database-updates.sh = execute-database-updates.sh + execute-database-migrations.sh = execute-database-migrations.sh EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Covid19Api.IoC", "src\Covid19Api.IoC\Covid19Api.IoC.csproj", "{783AD7D5-5C4D-4A63-86DE-543B972F3F46}" diff --git a/execute-database-migrations.sh b/execute-database-migrations.sh new file mode 100755 index 0000000..8509986 --- /dev/null +++ b/execute-database-migrations.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +function build() { + dotnet build -c Release src/Covid19Api.Mongo.Migrator/Covid19Api.Mongo.Migrator.csproj -o publish +} + + +function execute() { + dotnet ./publish/Covid19Api.Mongo.Migrator.dll +} + +build +execute +exit ${?} \ No newline at end of file diff --git a/execute-database-updates.sh b/execute-database-updates.sh new file mode 100755 index 0000000..1099c34 --- /dev/null +++ b/execute-database-updates.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +function build() { + dotnet build -c Release src/Covid19Api.Mongo.Scaffolder/Covid19Api.Mongo.Scaffolder.csproj -o publish +} + + +function execute() { + dotnet ./publish/Covid19Api.Mongo.Scaffolder.dll +} + +build +execute +exit ${?} \ No newline at end of file