2018-08-28 22:32:24 +02:00
|
|
|
stages:
|
|
|
|
- build
|
2020-06-19 22:20:05 +02:00
|
|
|
- docker
|
2018-08-28 22:32:24 +02:00
|
|
|
- deploy
|
2020-06-19 22:20:05 +02:00
|
|
|
- ops
|
2018-08-28 22:32:24 +02:00
|
|
|
|
2020-08-08 20:53:50 +02:00
|
|
|
variables:
|
2021-01-24 22:20:59 +01:00
|
|
|
VERSION: 4.3.0-V$CI_COMMIT_SHORT_SHA
|
2020-08-08 20:53:50 +02:00
|
|
|
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
2020-06-20 00:43:59 +02:00
|
|
|
|
2020-06-19 22:20:05 +02:00
|
|
|
Build:
|
2018-08-28 22:32:24 +02:00
|
|
|
stage: build
|
2021-03-19 00:21:35 +01:00
|
|
|
image: mcr.microsoft.com/dotnet/sdk:6.0
|
2018-08-28 22:32:24 +02:00
|
|
|
artifacts:
|
|
|
|
expire_in: 1h
|
|
|
|
paths:
|
2020-06-19 22:20:05 +02:00
|
|
|
- app
|
2018-08-28 22:32:24 +02:00
|
|
|
script:
|
2019-10-26 22:20:22 +02:00
|
|
|
- dotnet restore
|
2020-08-13 17:47:28 +02:00
|
|
|
- dotnet test tests
|
2021-01-24 22:20:59 +01:00
|
|
|
- dotnet publish --version-suffix "$VERSION" -r linux-x64 -c Release -o ./app ./src/Bot/
|
2018-08-28 22:32:24 +02:00
|
|
|
|
2020-06-19 22:20:05 +02:00
|
|
|
Package:
|
|
|
|
stage: docker
|
|
|
|
image: docker
|
2020-06-20 00:43:59 +02:00
|
|
|
only:
|
|
|
|
- master
|
2020-06-19 22:20:05 +02:00
|
|
|
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
|
2019-03-02 07:57:43 +01:00
|
|
|
|
2020-06-19 22:20:05 +02:00
|
|
|
Deploy:
|
2018-08-28 22:32:24 +02:00
|
|
|
stage: deploy
|
2020-06-20 00:43:59 +02:00
|
|
|
image: ansible/ansible-runner
|
2018-08-28 22:32:24 +02:00
|
|
|
only:
|
|
|
|
- master
|
2020-06-20 00:43:59 +02:00
|
|
|
variables:
|
|
|
|
ANSIBLE_NOCOWS: 1
|
2018-08-28 22:32:24 +02:00
|
|
|
before_script:
|
2020-06-20 00:43:59 +02:00
|
|
|
- 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
|
2018-08-28 22:32:24 +02:00
|
|
|
script:
|
2020-06-20 00:43:59 +02:00
|
|
|
- ansible-playbook -i $PROD_IP, .deploy.yml
|
2018-08-28 22:32:24 +02:00
|
|
|
|
2020-06-19 22:20:05 +02:00
|
|
|
Sentry:
|
|
|
|
stage: ops
|
|
|
|
image: getsentry/sentry-cli
|
|
|
|
allow_failure: true
|
|
|
|
only:
|
|
|
|
- master
|
|
|
|
script:
|
2020-08-08 20:53:50 +02:00
|
|
|
- sentry-cli releases new -p geekbot $VERSION
|
|
|
|
- sentry-cli releases set-commits --auto $VERSION
|
|
|
|
- sentry-cli releases deploys $VERSION new -e Production
|
2020-06-19 22:20:05 +02:00
|
|
|
|
|
|
|
Github Mirror:
|
|
|
|
stage: ops
|
2018-08-29 22:49:13 +02:00
|
|
|
image: runebaas/rsync-ssh-git
|
2018-08-28 22:32:24 +02:00
|
|
|
only:
|
|
|
|
- master
|
|
|
|
script:
|
|
|
|
- git push https://runebaas:$TOKEN@github.com/pizzaandcoffee/Geekbot.net.git origin/master:master -f
|