I'm new to CI/CD on Gitlab and would like some help filling in the gaps for setting up a pipeline for a Visual Studio solution containing multiple .NET Core projects.
I'm hoping for a process something like this:
- Pass in a PROJECT_NAME variable to the CI runner which specifies which project in the solution to build/publish.
- The runner builds the image using the .NET Core 3.1 SDK image.
- The runner publishes the image to the container registry.
- The runner fires off a webhook to a predefined webhook URL on the target server where the image should be deployed.
- The webhook triggers a redeploy of the container on the host with the new image.
This is what I've put together so far for my .gitlab-ci.yml file but I'm not sure if this is correct or what to do next?
stages:
- build
- publish
build:
stage: build
image: mcr.microsoft.com/dotnet/core/sdk:3.1-buster
only:
- master
script:
- cd $PROJECT_NAME
- dotnet restore
- dotnet build -c Release
- dotnet publish -c Release
artifacts:
paths:
- ./bin/Release/netcoreapp3.1/publish/*
expire_in: 1 week
tags:
- docker
publish:
stage: publish
image: docker:stable
services:
- docker:dind
only:
- master
before_script:
- docker login registry.gitlab.com -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD
script:
- docker build -t $CI_REGISTRY/$PROJECT_NAME .
- docker push $CI_REGISTRY/$PROJECT_NAME
after_script:
- docker logout $CI_REGISTRY
- curl -H "Authorization: Bearer $WEBHOOK_ACCESS_TOKEN" $WEBHOOK_URL
tags:
- docker
Any pointers would be appreciated.
Thanks in advance.