Files
wahlrecht/.drone.yml
T
2martens 8381c1ba7d
continuous-integration/drone/push Build is failing
Use Drone semver
2023-08-17 23:07:16 +02:00

159 lines
3.6 KiB
YAML

---
kind: pipeline
name: code quality
type: docker
platform:
os: linux
arch: arm64
clone:
skip_verify: true
steps:
- name: run code analysis
pull: always
image: 2martens/qodana-jvm-community-drone-plugin:2023.2
settings:
qodana_token:
from_secret: qodana_token
args: --baseline qodana.sarif.json --fail-threshold 0
volumes:
- name: cache
path: /data/cache
volumes:
- name: cache
host:
path: /var/lib/drone/cache
trigger:
event:
include:
- push
- pull_request
- custom
---
kind: pipeline
name: build image
type: docker
platform:
os: linux
arch: arm64
clone:
disable: true
steps:
- name: clone
image: alpine/git
environment:
SSH_KEY:
from_secret: ssh_key
commands:
- mkdir $HOME/.ssh
- echo "$SSH_KEY" > $HOME/.ssh/id_ed25519
- chmod 600 $HOME/.ssh/id_ed25519
- touch $HOME/.ssh/known_hosts
- chmod 600 $HOME/.ssh/known_hosts
- ssh-keyscan -H git.2martens.de > $HOME/.ssh/known_hosts 2>/dev/null
- git clone ssh://giteajim@git.2martens.de:22/2martens/wahlrecht.git .
- git checkout $DRONE_COMMIT
- name: build Docker container
image: gradle:8.2-jdk17
environment:
USERNAME:
from_secret: docker_username
PASSWORD:
from_secret: docker_password
SSH_KEY:
from_secret: ssh_key
volumes:
- name: cache
path: /home/gradle/.gradle
commands:
- mkdir $HOME/.ssh
- echo "$SSH_KEY" > $HOME/.ssh/id_ed25519
- chmod 600 $HOME/.ssh/id_ed25519
- touch $HOME/.ssh/known_hosts
- chmod 600 $HOME/.ssh/known_hosts
- ssh-keyscan -H git.2martens.de > $HOME/.ssh/known_hosts 2>/dev/null
- ./gradlew -Prelease.useLastTag=true final jib
volumes:
- name: cache
host:
path: /var/lib/drone/cache/.gradle
trigger:
event:
include:
- tag
- custom
---
kind: pipeline
name: deploy image
type: docker
platform:
os: linux
arch: arm64
clone:
disable: true
steps:
- name: clone
image: alpine/git
environment:
SSH_KEY:
from_secret: ssh_key
commands:
- mkdir $HOME/.ssh
- echo "$SSH_KEY" > $HOME/.ssh/id_ed25519
- chmod 600 $HOME/.ssh/id_ed25519
- touch $HOME/.ssh/known_hosts
- chmod 600 $HOME/.ssh/known_hosts
- ssh-keyscan -H git.2martens.de > $HOME/.ssh/known_hosts 2>/dev/null
- git clone ssh://giteajim@git.2martens.de:22/2martens/cloud-configuration.git .
- git checkout main
- name: modify deployed image
image: alpine
commands:
- sed -i -r "s/(wahlrecht_image_version:).*/\1\ ${DRONE_SEMVER}/" ansible/inventories/host_vars/api-server/public.yaml
- name: save modified variable file
image: alpine/git
environment:
SSH_KEY:
from_secret: ssh_key
commands:
- mkdir $HOME/.ssh
- echo "$SSH_KEY" > $HOME/.ssh/id_ed25519
- chmod 600 $HOME/.ssh/id_ed25519
- touch $HOME/.ssh/known_hosts
- chmod 600 $HOME/.ssh/known_hosts
- ssh-keyscan -H git.2martens.de > $HOME/.ssh/known_hosts 2>/dev/null
- git add ansible/inventories/host_vars/api-server/public.yaml
- git commit -m "[Drone] Changed wahlrecht_image_version to ${DRONE_SEMVER}"
- git push origin main
- name: deploy image
image: plugins/ansible:latest
settings:
playbook: ansible/deploy_spring.yaml
inventory: ansible/inventories/production
private_key:
from_secret: ssh_key
vault_password:
from_secret: vault_password
trigger:
target:
- production
event:
include:
- promote
- rollback