137 lines
3.2 KiB
YAML
137 lines
3.2 KiB
YAML
{{- range $i, $plat := .input.platforms -}}
|
|
---
|
|
kind: pipeline
|
|
type: kubernetes
|
|
name: build-{{ $plat.os }}-{{ $plat.arch }}
|
|
|
|
trigger:
|
|
event:
|
|
- push
|
|
branch:
|
|
{{ if $.input.build_branches -}}
|
|
{{ range $.input.build_branches }}- {{ . }}{{ end }}
|
|
{{ else }}- master{{- end }}
|
|
|
|
platform:
|
|
os: {{ $plat.os }}
|
|
arch: {{ $plat.arch }}
|
|
|
|
node_selector:
|
|
kubernetes.io/os: {{ $plat.os }}
|
|
kubernetes.io/arch: {{ $plat.arch }}
|
|
|
|
steps:
|
|
- name: build
|
|
image: plugins/docker
|
|
settings:
|
|
registry: https://gitea.internal.example.com
|
|
username: drone
|
|
password:
|
|
from_secret: gitea-internal-password
|
|
repo: gitea.internal.example.com/{{ $.input.repo }}
|
|
cache_from: gitea.internal.example.com/{{ $.input.repo }}:ci-{{ $plat.os }}-{{ $plat.arch }}
|
|
build_args:
|
|
- OS={{ $plat.os }}
|
|
- ARCH={{ $plat.arch }}
|
|
{{ range $.input.build_args }}
|
|
- {{ . }}
|
|
{{ end }}
|
|
tags:
|
|
- ci-{{ $plat.os }}-{{ $plat.arch }}
|
|
|
|
---
|
|
kind: pipeline
|
|
type: kubernetes
|
|
name: publish-{{ $plat.os }}-{{ $plat.arch }}
|
|
|
|
trigger:
|
|
event:
|
|
- promote
|
|
target:
|
|
- publish
|
|
- publish-{{ $plat.os }}-{{ $plat.arch }}
|
|
|
|
platform:
|
|
os: {{ $plat.os }}
|
|
arch: {{ $plat.arch }}
|
|
|
|
node_selector:
|
|
kubernetes.io/os: {{ $plat.os }}
|
|
kubernetes.io/arch: {{ $plat.arch }}
|
|
|
|
steps:
|
|
- name: build-and-publish
|
|
image: plugins/docker
|
|
settings:
|
|
registry: https://gitea.internal.example.com
|
|
username: drone
|
|
password:
|
|
from_secret: gitea-internal-password
|
|
repo: gitea.internal.example.com/{{ $.input.repo }}
|
|
cache_from: gitea.internal.example.com/{{ $.input.repo }}:ci-{{ $plat.os }}-{{ $plat.arch }}
|
|
build_args:
|
|
- OS={{ $plat.os }}
|
|
- ARCH={{ $plat.arch }}
|
|
{{ range $.input.build_args }}
|
|
- {{ . }}
|
|
{{ end }}
|
|
tags:
|
|
{{ range $.input.tags }}
|
|
- {{ . }}-{{ $plat.os }}-{{ $plat.arch }}
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
---
|
|
kind: pipeline
|
|
type: kubernetes
|
|
name: publish-multiarch-manifest
|
|
|
|
trigger:
|
|
event:
|
|
- promote
|
|
target:
|
|
- publish
|
|
|
|
{{ if .input.publish_multiarch_from }}
|
|
platform:
|
|
os: {{ .input.publish_multiarch_from.os }}
|
|
arch: {{ .input.publish_multiarch_from.arch }}
|
|
|
|
node_selector:
|
|
kubernetes.io/os: {{ .input.publish_multiarch_from.os }}
|
|
kubernetes.io/arch: {{ .input.publish_multiarch_from.arch }}
|
|
{{ end }}
|
|
|
|
steps:
|
|
- name: deploy
|
|
image: gitea.internal.example.com/examples/docker:latest{{ if .input.publish_multiarch_from }}-{{ .input.publish_multiarch_from.os }}-{{ .input.publish_multiarch_from.arch }}{{ end }}
|
|
volumes:
|
|
- name: dockersock
|
|
path: /var/run/
|
|
environment:
|
|
DOCKER_REGISTRY: https://gitea.internal.example.com
|
|
DOCKER_USER: drone
|
|
DOCKER_PASS:
|
|
from_secret: gitea-internal-password
|
|
commands:
|
|
- /bin/docker-setup
|
|
{{ range $i, $tag := $.input.tags }}
|
|
- |
|
|
docker manifest create \
|
|
gitea.internal.example.com/{{ $.input.repo }}:{{ $tag }} \
|
|
{{ range $.input.platforms -}}
|
|
gitea.internal.example.com/{{ $.input.repo }}:{{ $tag }}-{{ .os }}-{{ .arch }} \
|
|
{{- end }}
|
|
- docker manifest push gitea.internal.example.com/{{ $.input.repo }}:{{ $tag }}
|
|
{{ end }}
|
|
|
|
volumes:
|
|
- name: dockersock
|
|
host:
|
|
path: /var/run/
|
|
|
|
depends_on:
|
|
{{ range .input.platforms }}
|
|
- publish-{{ .os }}-{{ .arch }}
|
|
{{ end }}
|