--- image: mcr.microsoft.com/dotnet/core/sdk:3.0-alpine3.11 variables: OBJECTS_DIRECTORY: 'obj' NUGET_PACKAGES_DIRECTORY: '.nuget' SOURCE_CODE_PATH: 'ChaosBot/*/' stages: - build - test - release - deploy cache: key: "$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG" paths: # Specify three paths that should be cached: # # 1) Main JSON file holding information about package dependency tree, packages versions, # frameworks etc. It also holds information where to the dependencies were restored. - '$SOURCE_CODE_PATH$OBJECTS_DIRECTORY/project.assets.json' # 2) Other NuGet and MSBuild related files. Also needed. - '$SOURCE_CODE_PATH$OBJECTS_DIRECTORY/*.csproj.nuget.*' # 3) Path to the directory where restored dependencies are kept. - '$NUGET_PACKAGES_DIRECTORY' # policy: pull-push before_script: - 'dotnet restore --packages $NUGET_PACKAGES_DIRECTORY' build: stage: build only: changes: - ChaosBot/**/* refs: - master tags: - docker - hawkeye script: - 'dotnet build --no-restore' tests: stage: test only: changes: - ChaosBot/**/* refs: - master dependencies: - build tags: - docker - hawkeye script: - 'dotnet test --no-restore' release: stage: release only: changes: - ChaosBot/**/* refs: - master dependencies: - tests tags: - docker - hawkeye script: - 'dotnet publish -c Release -r linux-musl-x64 -o ../build --self-contained true' artifacts: paths: - build/* deploy: stage: deploy only: changes: - ChaosBot/**/* refs: - master tags: - docker - hawkeye dependencies: - release script: - 'apk add lftp openssh-client curl jq' - 'mkdir ~/.ssh' - 'ssh-keyscan -p 2303 panel.chaoticlogic.us >> ~/.ssh/known_hosts' - 'echo "LFTP needs to be fixed"' - 'lftp sftp://$SFTP_USER:$SFTP_PASS@$SFTP_HOST -e "mirror -X .* -X .*/ -X *.db -X appsettings.json --reverse --verbose --delete --parallel=8 build/ ./; bye"' # - 'curl -X POST $API_URI/api/endpoints/$ENDPOINT_URI/docker/containers/$CONTAINER_ID/restart -H "Authorization: Bearer `curl -X POST $API_URI/api/auth -H "Content-Type: application/json" -d "{\"Username\": \"$API_USER\", \"Password\": \"$API_PASS\"}"" | jq -r ".jwt"`"'