stages: - build - docker - deploy - ops variables: VERSION: 4.3.0-V$CI_COMMIT_SHORT_SHA IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG Build: stage: build image: mcr.microsoft.com/dotnet/sdk:6.0 artifacts: expire_in: 1h paths: - app script: - dotnet restore - dotnet test tests - dotnet publish --version-suffix "$VERSION" -r linux-x64 -c Release -p:DebugType=embedded --no-self-contained -o ./app ./src/Startup/ Package: stage: docker image: docker only: - master services: - docker:stable-dind script: - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - docker build -t $IMAGE_TAG . - docker push $IMAGE_TAG Deploy: stage: deploy image: ansible/ansible-runner only: - master variables: ANSIBLE_NOCOWS: 1 before_script: - mkdir /root/.ssh - cp $SSH_PRIVATE_KEY /root/.ssh/id_ed25519 - cp $SSH_PUBLIC_KEY /root/.ssh/id_ed25519.pub - chmod -R 600 /root/.ssh - ssh-keyscan -p 65432 $PROD_IP > /root/.ssh/known_hosts script: - ansible-playbook -i $PROD_IP, .deploy.yml Sentry: stage: ops image: getsentry/sentry-cli allow_failure: true only: - master script: - sentry-cli releases new -p geekbot $VERSION - sentry-cli releases set-commits --auto $VERSION - sentry-cli releases deploys $VERSION new -e Production Github Mirror: stage: ops image: runebaas/rsync-ssh-git only: - master script: - git push https://runebaas:$TOKEN@github.com/pizzaandcoffee/Geekbot.net.git origin/master:master -f