refactoring

This commit is contained in:
Robert Kaussow 2020-02-04 10:49:12 +01:00
parent 0f04eed106
commit 7972f7321c
4 changed files with 70 additions and 98 deletions

View File

@ -1,38 +1,38 @@
local PipelineBuild(os='linux', arch='amd64') = { local PipelineBuild(arch='amd64') = {
local tag = os + '-' + arch, local tag = 'linux-' + arch,
local version_tag = os + '-' + arch, kind: 'pipeline',
local file_suffix = std.strReplace(version_tag, '-', '.'), name: 'build-container-' + arch,
kind: "pipeline",
name: version_tag,
platform: { platform: {
os: os, os: 'linux',
arch: arch, arch: arch,
}, },
steps: [ steps: [
{ {
name: 'dryrun', name: 'dryrun',
image: 'plugins/docker:' + tag, image: 'plugins/docker:' + tag,
pull: 'always',
settings: { settings: {
dry_run: true, dry_run: true,
tags: version_tag, dockerfile: './Dockerfile.' + arch,
dockerfile: './Dockerfile.' + file_suffix,
repo: 'xoxys/nginx', repo: 'xoxys/nginx',
username: { from_secret: "docker_username" }, username: { from_secret: 'docker_username' },
password: { from_secret: "docker_password" }, password: { from_secret: 'docker_password' },
},
when: {
ref: [
'refs/pull/**',
],
}, },
}, },
{ {
name: 'publish', name: 'publish',
image: 'plugins/docker:' + tag, image: 'plugins/docker:' + tag,
pull: 'always',
settings: { settings: {
auto_tag: true, auto_tag: true,
auto_tag_suffix: version_tag, auto_tag_suffix: arch,
dockerfile: './Dockerfile.' + file_suffix, dockerfile: './Dockerfile.' + arch,
repo: 'xoxys/nginx', repo: 'xoxys/nginx',
username: { from_secret: "docker_username" }, username: { from_secret: 'docker_username' },
password: { from_secret: "docker_password" }, password: { from_secret: 'docker_password' },
}, },
when: { when: {
ref: [ ref: [
@ -45,82 +45,64 @@ local PipelineBuild(os='linux', arch='amd64') = {
}; };
local PipelineNotifications(depends_on=[]) = { local PipelineNotifications(depends_on=[]) = {
kind: "pipeline", kind: 'pipeline',
name: "notifications", name: 'notifications',
platform: { platform: {
os: "linux", os: 'linux',
arch: "amd64", arch: 'amd64',
}, },
steps: [ steps: [
{ {
image: "plugins/manifest", image: 'plugins/manifest',
name: "manifest", name: 'manifest',
pull: "always",
settings: { settings: {
ignore_missing: true, ignore_missing: true,
username: { from_secret: "docker_username" }, tags: ['${DRONE_TAG}', '${DRONE_TAG%-*}', '${DRONE_TAG%.*}', '${DRONE_TAG%%.*}'],
password: { from_secret: "docker_password" }, username: { from_secret: 'docker_username' },
spec: "./manifest.tmpl", password: { from_secret: 'docker_password' },
}, spec: './manifest.tmpl',
when: {
ref: [
'refs/heads/master',
'refs/tags/**',
],
}, },
}, },
{ {
name: "readme", name: 'readme',
image: "sheogorath/readme-to-dockerhub", image: 'sheogorath/readme-to-dockerhub',
pull: "always",
environment: { environment: {
DOCKERHUB_USERNAME: { from_secret: "docker_username" }, DOCKERHUB_USERNAME: { from_secret: 'docker_username' },
DOCKERHUB_PASSWORD: { from_secret: "docker_password" }, DOCKERHUB_PASSWORD: { from_secret: 'docker_password' },
DOCKERHUB_REPO_PREFIX: "xoxys", DOCKERHUB_REPO_PREFIX: 'xoxys',
DOCKERHUB_REPO_NAME: "nginx", DOCKERHUB_REPO_NAME: 'nginx',
README_PATH: "README.md", README_PATH: 'README.md',
SHORT_DESCRIPTION: "Rootless NGINX - High-performance HTTP server and reverse proxy" SHORT_DESCRIPTION: 'Rootless NGINX - High-performance HTTP server and reverse proxy',
},
when: {
ref: [
'refs/heads/master',
'refs/tags/**',
],
}, },
}, },
{ {
name: "microbadger", image: 'plugins/matrix',
image: "plugins/webhook", name: 'matrix',
pull: "always",
settings: { settings: {
urls: { from_secret: "microbadger_url" }, homeserver: 'https://matrix.rknet.org',
}, roomid: 'MtidqQXWWAtQcByBhH:rknet.org',
}, template: 'Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}',
{ username: { from_secret: 'matrix_username' },
image: "plugins/matrix", password: { from_secret: 'matrix_password' },
name: "matrix",
pull: 'always',
settings: {
homeserver: "https://matrix.rknet.org",
roomid: "MtidqQXWWAtQcByBhH:rknet.org",
template: "Status: **{{ build.status }}**<br/> Build: [{{ repo.Owner }}/{{ repo.Name }}]({{ build.link }}) ({{ build.branch }}) by {{ build.author }}<br/> Message: {{ build.message }}",
username: { from_secret: "matrix_username" },
password: { from_secret: "matrix_password" },
}, },
when: { when: {
status: [ "success", "failure" ], status: ['success', 'failure'],
}, },
}, },
], ],
trigger: { trigger: {
status: [ "success", "failure" ], ref: [
'refs/heads/master',
'refs/tags/**',
],
status: ['success', 'failure'],
}, },
depends_on: depends_on, depends_on: depends_on,
}; };
[ [
PipelineBuild(os='linux', arch='amd64'), PipelineBuild(arch='amd64'),
PipelineNotifications(depends_on=[ PipelineNotifications(depends_on=[
"linux-amd64", 'build-container-amd64',
]) ]),
] ]

View File

@ -1,6 +1,6 @@
--- ---
kind: pipeline kind: pipeline
name: linux-amd64 name: build-container-amd64
platform: platform:
os: linux os: linux
@ -8,25 +8,25 @@ platform:
steps: steps:
- name: dryrun - name: dryrun
pull: always
image: plugins/docker:linux-amd64 image: plugins/docker:linux-amd64
settings: settings:
dockerfile: ./Dockerfile.linux.amd64 dockerfile: ./Dockerfile.amd64
dry_run: true dry_run: true
password: password:
from_secret: docker_password from_secret: docker_password
repo: xoxys/nginx repo: xoxys/nginx
tags: linux-amd64
username: username:
from_secret: docker_username from_secret: docker_username
when:
ref:
- refs/pull/**
- name: publish - name: publish
pull: always
image: plugins/docker:linux-amd64 image: plugins/docker:linux-amd64
settings: settings:
auto_tag: true auto_tag: true
auto_tag_suffix: linux-amd64 auto_tag_suffix: amd64
dockerfile: ./Dockerfile.linux.amd64 dockerfile: ./Dockerfile.amd64
password: password:
from_secret: docker_password from_secret: docker_password
repo: xoxys/nginx repo: xoxys/nginx
@ -35,7 +35,7 @@ steps:
when: when:
ref: ref:
- refs/heads/master - refs/heads/master
- "refs/tags/**" - refs/tags/**
--- ---
kind: pipeline kind: pipeline
@ -47,22 +47,21 @@ platform:
steps: steps:
- name: manifest - name: manifest
pull: always
image: plugins/manifest image: plugins/manifest
settings: settings:
ignore_missing: true ignore_missing: true
password: password:
from_secret: docker_password from_secret: docker_password
spec: ./manifest.tmpl spec: ./manifest.tmpl
tags:
- ${DRONE_TAG}
- ${DRONE_TAG%-*}
- ${DRONE_TAG%.*}
- ${DRONE_TAG%%.*}
username: username:
from_secret: docker_username from_secret: docker_username
when:
ref:
- refs/heads/master
- "refs/tags/**"
- name: readme - name: readme
pull: always
image: sheogorath/readme-to-dockerhub image: sheogorath/readme-to-dockerhub
environment: environment:
DOCKERHUB_PASSWORD: DOCKERHUB_PASSWORD:
@ -73,20 +72,8 @@ steps:
from_secret: docker_username from_secret: docker_username
README_PATH: README.md README_PATH: README.md
SHORT_DESCRIPTION: Rootless NGINX - High-performance HTTP server and reverse proxy SHORT_DESCRIPTION: Rootless NGINX - High-performance HTTP server and reverse proxy
when:
ref:
- refs/heads/master
- "refs/tags/**"
- name: microbadger
pull: always
image: plugins/webhook
settings:
urls:
from_secret: microbadger_url
- name: matrix - name: matrix
pull: always
image: plugins/matrix image: plugins/matrix
settings: settings:
homeserver: https://matrix.rknet.org homeserver: https://matrix.rknet.org
@ -102,15 +89,18 @@ steps:
- failure - failure
trigger: trigger:
ref:
- refs/heads/master
- refs/tags/**
status: status:
- success - success
- failure - failure
depends_on: depends_on:
- linux-amd64 - build-container-amd64
--- ---
kind: signature kind: signature
hmac: 9619ca3e3158f7e30d6f7c80939260f2e30c3321349f24bdeb4cdfc229768fdb hmac: 18d51c3100fde1f5f7a1813aeb14fff653ae509b4040e492d2420486201988eb
... ...

View File

@ -6,7 +6,7 @@ tags:
{{/each}} {{/each}}
{{/if}} {{/if}}
manifests: manifests:
- image: xoxys/nginx:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64 - image: xoxys/nginx:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}amd64
platform: platform:
architecture: amd64 architecture: amd64
os: linux os: linux