synchronization
This commit is contained in:
72
CICD/Drone/YML/.drone-build-webhook.yml
Normal file
72
CICD/Drone/YML/.drone-build-webhook.yml
Normal file
@@ -0,0 +1,72 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Build Dockerfile
|
||||
|
||||
# 手动触发或接口触发
|
||||
trigger:
|
||||
event:
|
||||
- custom
|
||||
|
||||
# 指定架构,需在 runner 配置环境变量中指定 DRONE_RUNNER_ARCH,或自动获取
|
||||
# platform:
|
||||
# os: linux
|
||||
# arch: amd64
|
||||
|
||||
# 指定运行环境节点,需在 runner 配置环境变量中指定 DRONE_RUNNER_LABELS
|
||||
# node:
|
||||
# 标签:值
|
||||
|
||||
# 使用插件构建镜像
|
||||
steps:
|
||||
- name: Build Dockerfile
|
||||
image: plugins/docker
|
||||
# 仅当本地不存在该镜像时才拉取
|
||||
pull: if-not-exists
|
||||
settings:
|
||||
registry:
|
||||
from_secret: REGISTRY
|
||||
username:
|
||||
from_secret: DOCKER_USERNAME
|
||||
password:
|
||||
from_secret: DOCKER_PASSWORD
|
||||
repo:
|
||||
from_secret: REPO
|
||||
# 是否禁止推送镜像
|
||||
dry_run: false
|
||||
tags:
|
||||
- latest
|
||||
# 要使用的上下文路径,默认为 git 存储库的根目录
|
||||
context: ./
|
||||
# 要使用的 dockerfile 路径,默认为 git 存储库的根目录
|
||||
dockerfile: ./Dockerfile
|
||||
- name: 结果通知
|
||||
image: plugins/webhook
|
||||
depends_on: [Build Dockerfile]
|
||||
settings:
|
||||
urls:
|
||||
from_secret: WEBHOOK_URL
|
||||
|
||||
# # 飞书机器人
|
||||
# 官网飞书机器人使用指南: https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot
|
||||
# 消息类型指南: https://open.feishu.cn/community/articles/7271149634339422210
|
||||
method: POST
|
||||
content_type: "application/json"
|
||||
# 通知内容,读取上一步执行结果,如果成功则返回构建成功,失败则返回构建失败
|
||||
template: >
|
||||
{
|
||||
"msg_type": "text",
|
||||
"content": {
|
||||
"text":
|
||||
{{#success build.status}}
|
||||
"镜像构建成功"
|
||||
{{else}}
|
||||
"镜像构建失败"
|
||||
{{/success}}
|
||||
}
|
||||
}
|
||||
|
||||
# 无论构建成功或失败都通知
|
||||
when:
|
||||
status:
|
||||
- success
|
||||
- failure
|
38
CICD/Drone/YML/.drone-buildx.yml
Normal file
38
CICD/Drone/YML/.drone-buildx.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Build Dockerfile
|
||||
|
||||
# 手动触发或接口触发
|
||||
trigger:
|
||||
event:
|
||||
- custom
|
||||
|
||||
# 指定运行环境节点,需在 runner 配置环境变量中指定 DRONE_RUNNER_LABELS
|
||||
# node:
|
||||
# 标签:值
|
||||
|
||||
# 使用插件构建镜像
|
||||
steps:
|
||||
- name: latest
|
||||
image: thegeeklab/drone-docker-buildx
|
||||
privileged: true
|
||||
settings:
|
||||
registry:
|
||||
from_secret: REGISTRY
|
||||
username:
|
||||
from_secret: DOCKER_USERNAME
|
||||
password:
|
||||
from_secret: DOCKER_PASSWORD
|
||||
repo:
|
||||
from_secret: REPO
|
||||
purge: true
|
||||
compress: true
|
||||
platforms:
|
||||
- linux/amd64
|
||||
- linux/arm64
|
||||
context: ./
|
||||
dockerfile: ./Dockerfile
|
||||
tags: latest
|
||||
when:
|
||||
branch:
|
||||
- main
|
22
CICD/Drone/YML/.drone-deploy.yml
Normal file
22
CICD/Drone/YML/.drone-deploy.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
kind: pipeline
|
||||
name: default
|
||||
|
||||
trigger:
|
||||
event:
|
||||
include:
|
||||
- custom
|
||||
|
||||
steps:
|
||||
- name: Update-Deployment
|
||||
image: quay.io/honestbee/drone-kubernetes
|
||||
settings:
|
||||
kubernetes_server:
|
||||
from_secret: KUBERNESTES_SERVER
|
||||
kubernetes_token:
|
||||
from_secret: KUBERNESTES_TOKEN
|
||||
namespace: default
|
||||
deployment: nginx
|
||||
repo: nginx
|
||||
container: nginx
|
||||
tag:
|
||||
- latest
|
61
CICD/Drone/YML/.drone-dind.yml
Normal file
61
CICD/Drone/YML/.drone-dind.yml
Normal file
@@ -0,0 +1,61 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Build Dockerfile
|
||||
|
||||
# platform:
|
||||
# os: linux
|
||||
# arch: amd64
|
||||
|
||||
# 手动触发或接口触发
|
||||
trigger:
|
||||
event:
|
||||
- custom
|
||||
|
||||
steps:
|
||||
- name: Dockerfile
|
||||
image: docker:dind
|
||||
|
||||
# 挂载Docker守护进程
|
||||
volumes:
|
||||
- name: dockersock
|
||||
path: /var/run/docker.sock
|
||||
|
||||
# 环境变量
|
||||
environment:
|
||||
DOCKER_USERNAME:
|
||||
from_secret: DOCKER_USERNAME
|
||||
DOCKER_PASSWORD:
|
||||
from_secret: DOCKER_PASSWORD
|
||||
NAMESPACE:
|
||||
from_secret: NAMESPACE
|
||||
# 镜像名
|
||||
IMAGENAME: demo
|
||||
# 镜像标签
|
||||
IMAGETAG: latest
|
||||
# 镜像仓库私有地址
|
||||
REGISTRY:
|
||||
from_secret: REGISTRY
|
||||
|
||||
# 执行命令
|
||||
commands:
|
||||
# 推送镜像至阿里云
|
||||
# - docker build -t registry.cn-hangzhou.aliyuncs.com/$NAMESPACE/$IMAGENAME:$IMAGETAG .
|
||||
# - docker login registry.cn-hangzhou.aliyuncs.com -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
|
||||
# - docker push registry.cn-hangzhou.aliyuncs.com/$NAMESPACE/$IMAGENAME:$IMAGETAG
|
||||
|
||||
# 推送镜像至DockerHub
|
||||
# - docker build -t $DOCKER_USERNAME/$IMAGENAME:$IMAGETAG .
|
||||
# - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
|
||||
# - docker push $DOCKER_USERNAME/$IMAGENAME:$IMAGETAG
|
||||
|
||||
# 推送镜像至私有仓库
|
||||
- docker build -t $REGISTRY/$NAMESPACE/$IMAGENAME:$IMAGETAG .
|
||||
- docker login $REGISTRY -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
|
||||
- docker push $REGISTRY/$NAMESPACE/$IMAGENAME:$IMAGETAG
|
||||
|
||||
|
||||
# 挂载Docker守护进程
|
||||
volumes:
|
||||
- name: dockersock
|
||||
host:
|
||||
path: /var/run/docker.sock
|
24
CICD/Drone/YML/.drone-git-push.yml
Normal file
24
CICD/Drone/YML/.drone-git-push.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Git Push
|
||||
|
||||
# 手动触发或接口触发
|
||||
trigger:
|
||||
event:
|
||||
- custom
|
||||
|
||||
steps:
|
||||
- name: Git Push
|
||||
image: appleboy/drone-git-push
|
||||
# 仅当本地不存在该镜像时才拉取
|
||||
pull: if-not-exists
|
||||
settings:
|
||||
branch: main
|
||||
remote:
|
||||
from_secret: REMOTE
|
||||
ssh_key:
|
||||
from_secret: SSH_KEY
|
||||
path:
|
||||
force: false
|
||||
commit: true
|
||||
commit_message: "Update From Drone"
|
31
CICD/Drone/YML/.drone-scp.yml
Normal file
31
CICD/Drone/YML/.drone-scp.yml
Normal file
@@ -0,0 +1,31 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Scp File
|
||||
|
||||
# 手动触发或接口触发
|
||||
trigger:
|
||||
event:
|
||||
- custom
|
||||
|
||||
steps:
|
||||
- name: Scp File
|
||||
image: appleboy/drone-scp
|
||||
# 仅当本地不存在该镜像时才拉取
|
||||
pull: if-not-exists
|
||||
settings:
|
||||
host:
|
||||
from_secret: HOST
|
||||
user:
|
||||
from_secret: USER
|
||||
password:
|
||||
from_secret: PASSWORD
|
||||
port:
|
||||
from_secret: PORT
|
||||
# 源文件路径
|
||||
source: File/*
|
||||
strip_components: 1
|
||||
# 目标路径
|
||||
target: /root/
|
||||
when:
|
||||
branch:
|
||||
- main
|
29
CICD/Drone/YML/.drone-ssh.yml
Normal file
29
CICD/Drone/YML/.drone-ssh.yml
Normal file
@@ -0,0 +1,29 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Ssh Server
|
||||
|
||||
# 手动触发或接口触发
|
||||
trigger:
|
||||
event:
|
||||
- custom
|
||||
|
||||
steps:
|
||||
- name: Ssh Server
|
||||
image: appleboy/drone-ssh
|
||||
# 仅当本地不存在该镜像时才拉取
|
||||
pull: if-not-exists
|
||||
settings:
|
||||
host:
|
||||
from_secret: HOST
|
||||
user:
|
||||
from_secret: USER
|
||||
password:
|
||||
from_secret: PASSWORD
|
||||
port:
|
||||
from_secret: PORT
|
||||
# 执行命令
|
||||
script:
|
||||
- ls
|
||||
when:
|
||||
branch:
|
||||
- main
|
44
CICD/Drone/YML/.drone.yml
Normal file
44
CICD/Drone/YML/.drone.yml
Normal file
@@ -0,0 +1,44 @@
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: Build Dockerfile
|
||||
|
||||
# 手动触发或接口触发
|
||||
trigger:
|
||||
event:
|
||||
- custom
|
||||
|
||||
# 指定架构,需在 runner 配置环境变量中指定 DRONE_RUNNER_ARCH,或自动获取
|
||||
# platform:
|
||||
# os: linux
|
||||
# arch: amd64
|
||||
|
||||
# 指定运行环境节点,需在 runner 配置环境变量中指定 DRONE_RUNNER_LABELS
|
||||
# node:
|
||||
# 标签:值
|
||||
|
||||
# 使用插件构建镜像
|
||||
steps:
|
||||
- name: Build Dockerfile
|
||||
image: plugins/docker
|
||||
# 仅当本地不存在该镜像时才拉取
|
||||
pull: if-not-exists
|
||||
settings:
|
||||
registry:
|
||||
from_secret: REGISTRY
|
||||
username:
|
||||
from_secret: DOCKER_USERNAME
|
||||
password:
|
||||
from_secret: DOCKER_PASSWORD
|
||||
repo:
|
||||
from_secret: REPO
|
||||
# 是否禁止推送镜像
|
||||
dry_run: false
|
||||
tags:
|
||||
- latest
|
||||
# 要使用的上下文路径,默认为 git 存储库的根目录
|
||||
context: ./
|
||||
# 要使用的 dockerfile 路径,默认为 git 存储库的根目录
|
||||
dockerfile: ./Dockerfile
|
||||
when:
|
||||
branch:
|
||||
- main
|
Reference in New Issue
Block a user