# You can override the included template(s) by including variable overrides
# See https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#priority-of-environment-variables
image: busybox:latest
before_script:
- dotnet restore
- dotnet nuget remove source gitlab || true
nonreg:
  tags:
    - dotnet
  stage: test
  environment: Development
  script:
  - |
    echo "setting : $ISND_TESTING_SETTINGS"
    dotnet build
    cat $ISND_TESTING_SETTINGS > test/isnd.tests/appsettings.json
    dotnet test
publish:
  tags:
    - dotnet
  stage: deploy
  dependencies:
    - nonreg
  artifacts:
    paths:
    - src/isnd/bin/Release/netcoreapp2.1/publish/
    when: always
  script:
  - dotnet publish --configuration Release
deploy-to-gitlab:
  tags:
    - dotnet
  stage: deploy
  dependencies:
    - nonreg
  artifacts:
    paths:
    - src/*/bin/Release/*.nupkg
    when: always
  script:
  - dotnet pack -c Release
  - dotnet nuget add source --name gitlab --username gitlab+deploy-token-2 --password
    $CI_JOB_TOKEN --store-password-in-clear-text "$CI_SERVER_URL/api/v4/projects/$CI_PROJECT_ID/packages/nuget/index.json"
  - dotnet nuget push src/*/bin/Release/*.nupkg -s gitlab
deploy-to-isn:
  stage: deploy
  tags:
    - dotnet
  artifacts:
    paths:
    - src/*/bin/Release/*.nupkg
    when: always
  script:
  - dotnet pack --configuration Release --no-restore
  - cd src/isn
  - find -name "*.nupkg" -exec dotnet run push -s $ISNSOURCE -k $ISNAPIKEY {} \;
  environment:
    name: production
    url: $ISNSOURCE
  dependencies:
    - nonreg
stages:
- test
- deploy
