Add .drone.yml for CI/CD
This commit is contained in:
44
.drone.yml
Normal file
44
.drone.yml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
|
||||||
|
name: build-and-push
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: restore-cache
|
||||||
|
restore_cache:
|
||||||
|
keys:
|
||||||
|
- maven-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "pom.xml" }}
|
||||||
|
- maven-{{ .Environment.DRONE_REPO_NAME }}-
|
||||||
|
|
||||||
|
- name: build
|
||||||
|
image: maven:3.9-eclipse-temurin-17
|
||||||
|
commands:
|
||||||
|
- mvn clean package -DskipTests
|
||||||
|
cache_from:
|
||||||
|
- maven-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "pom.xml" }}
|
||||||
|
|
||||||
|
- name: build-image
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
repo: ccr.ccs.tencentyun.com/todo-{{ if eq .Branch "master" }}prod{{ else }}test{{ end }}/todo-backend
|
||||||
|
tags:
|
||||||
|
- {{ .Commit SHA }}
|
||||||
|
- {{ if eq .Branch "master" }}v1.0.0{{ else }}latest{{ end }}
|
||||||
|
username:
|
||||||
|
from_secret: registry_username
|
||||||
|
password:
|
||||||
|
from_secret: registry_password
|
||||||
|
when:
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
- dev
|
||||||
|
|
||||||
|
- name: rebuild-cache
|
||||||
|
rebuild_cache:
|
||||||
|
keys:
|
||||||
|
- maven-{{ .Environment.DRONE_REPO_NAME }}-{{ checksum "pom.xml" }}
|
||||||
|
- maven-{{ .Environment.DRONE_REPO_NAME }}-
|
||||||
Reference in New Issue
Block a user