65 lines
1.4 KiB
YAML
65 lines
1.4 KiB
YAML
|
|
||
|
kind: pipeline
|
||
|
type: docker
|
||
|
name: build
|
||
|
|
||
|
clone:
|
||
|
disable: true
|
||
|
|
||
|
trigger:
|
||
|
ref:
|
||
|
- refs/tags/**
|
||
|
- refs/heads/master
|
||
|
event:
|
||
|
- tag
|
||
|
|
||
|
steps:
|
||
|
- name: clone
|
||
|
image: alpine/git
|
||
|
environment:
|
||
|
SSH_PRIVATE_KEY:
|
||
|
from_secret: ssh_private_key
|
||
|
commands:
|
||
|
- umask 077
|
||
|
- mkdir -p /root/.ssh/
|
||
|
- echo "$$SSH_PRIVATE_KEY" > /root/.ssh/id_rsa
|
||
|
- ssh-keyscan -t rsa -p 2222 git.hxjscloud.com >> ~/.ssh/known_hosts
|
||
|
- test $${DRONE_TAG} && git clone --branch $DRONE_TAG $DRONE_GIT_SSH_URL .
|
||
|
- test $${DRONE_TAG} || git clone --branch $DRONE_BRANCH $DRONE_GIT_SSH_URL .
|
||
|
- SHORT_COMMIT_ID=$${DRONE_COMMIT:0-8}
|
||
|
- TAG_LIST="latest"
|
||
|
- test $${DRONE_TAG} && TAG_LIST="$${TAG_LIST},$${DRONE_TAG}"
|
||
|
- test $${DRONE_TAG} || TAG_LIST="$${TAG_LIST},snapshot-$(date +%Y%m%d)-$${SHORT_COMMIT_ID}"
|
||
|
- echo $${TAG_LIST} > .tags
|
||
|
|
||
|
- name: build
|
||
|
image: plugins/docker
|
||
|
settings:
|
||
|
auto_tag: true
|
||
|
repo: harbor.hxjscloud.com/ops/alertmanager-webhook
|
||
|
registry: harbor.hxjscloud.com
|
||
|
username:
|
||
|
from_secret: docker_username
|
||
|
password:
|
||
|
from_secret: docker_password
|
||
|
|
||
|
---
|
||
|
kind: secret
|
||
|
name: ssh_private_key
|
||
|
get:
|
||
|
path: kv/data/drone-ci
|
||
|
name: deploy_ssh_private_key
|
||
|
|
||
|
---
|
||
|
kind: secret
|
||
|
name: docker_username
|
||
|
get:
|
||
|
path: kv/data/drone-ci
|
||
|
name: registry_username
|
||
|
|
||
|
---
|
||
|
kind: secret
|
||
|
name: docker_password
|
||
|
get:
|
||
|
path: kv/data/drone-ci
|
||
|
name: registry_password
|