71 lines
1.6 KiB
YAML
71 lines
1.6 KiB
YAML
stages:
|
|
- build
|
|
- docker
|
|
- deploy
|
|
- ops
|
|
|
|
.imageTag: &IMAGE_TAG $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
|
|
|
Build:
|
|
stage: build
|
|
image: mcr.microsoft.com/dotnet/core/sdk:5.0-focal
|
|
artifacts:
|
|
expire_in: 1h
|
|
paths:
|
|
- app
|
|
script:
|
|
- dotnet restore
|
|
- dotnet test Tests
|
|
- dotnet publish --version-suffix ${CI_COMMIT_SHA:0:8} -r linux-x64 -c Release -o ./app ./Geekbot.net/
|
|
|
|
Package:
|
|
stage: docker
|
|
image: docker
|
|
only:
|
|
- master
|
|
- docker
|
|
services:
|
|
- docker:stable-dind
|
|
variables:
|
|
IMAGE_TAG: *IMAGE_TAG
|
|
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
|
|
- docker
|
|
variables:
|
|
ANSIBLE_NOCOWS: 1
|
|
IMAGE_TAG: *IMAGE_TAG
|
|
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 4.2.0-${CI_COMMIT_SHA:0:8}
|
|
- sentry-cli releases set-commits --auto 4.2.0-${CI_COMMIT_SHA:0:8}
|
|
- sentry-cli releases deploys 4.2.0-${CI_COMMIT_SHA:0:8} 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
|