forked from grafana/grizzly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrone.jsonnet
133 lines (122 loc) · 3.06 KB
/
drone.jsonnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
local golang = 'golang:1.16.2';
local volumes = [{ name: 'docker', host: { path: '/var/run/docker.sock' } }, { name: 'gopath', temp: {} }];
local mounts = [{ name: 'gopath', path: '/go' }, { name: 'docker', path: '/var/run/docker.sock' }];
local constraints = {
onlyTagOrMaster: { trigger: {
ref: [
'refs/heads/master',
'refs/heads/docker',
'refs/tags/v*',
],
} },
onlyTags: { trigger: {
event: ['tag'],
} },
always: {},
};
local go(name, commands) = {
name: name,
image: golang,
volumes: mounts,
commands: commands,
};
local make(target) = go(target, ['make ' + target]);
local pipeline(name) = {
kind: 'pipeline',
name: name,
type: 'docker',
volumes: volumes,
steps: [],
};
local docker(arch) = pipeline('docker-' + arch) {
platform: {
os: 'linux',
arch: arch,
},
steps: [
make('static'),
{
name: 'container',
image: 'plugins/docker',
settings: {
repo: 'grafana/grizzly',
auto_tag: true,
auto_tag_suffix: arch,
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
},
},
],
};
local vault_secret(name, vault_path, key) = {
kind: 'secret',
name: name,
get: {
path: vault_path,
name: key,
},
};
[
pipeline('check') {
services: [
{
name: 'grizzly-grafana',
image: 'alpine',
volumes: mounts,
commands: ['apk add docker make && make run-test-image'],
ports: [
3000,
],
},
],
steps: [
go('download', ['go mod download']),
make('lint') { depends_on: ['download'] },
go('test', ['go test ./...']),
],
} + constraints.always,
pipeline('release') {
steps: [
go('fetch-tags', ['git fetch origin --tags']),
make('cross'),
{
name: 'publish',
image: 'plugins/github-release',
settings: {
title: '${DRONE_TAG}',
note: importstr 'release-note.md',
api_key: { from_secret: 'github_token' },
files: 'dist/*',
draft: true,
},
},
],
} + { depends_on: ['check'] } + constraints.onlyTags,
docker('amd64') { depends_on: ['check'] } + constraints.onlyTagOrMaster,
docker('arm') { depends_on: ['check'] } + constraints.onlyTagOrMaster,
docker('arm64') { depends_on: ['check'] } + constraints.onlyTagOrMaster,
pipeline('manifest') {
steps: [{
name: 'manifest',
image: 'plugins/manifest',
settings: {
auto_tag: true,
ignore_missing: true,
spec: '.drone/docker-manifest.tmpl',
username: { from_secret: 'docker_username' },
password: { from_secret: 'docker_password' },
},
}],
} + {
depends_on: [
'docker-amd64',
'docker-arm',
'docker-arm64',
],
} + constraints.onlyTagOrMaster,
]
+ [
vault_secret('github_token', 'infra/data/ci/github/grafanabot', 'pat'),
vault_secret('docker_username', 'infra/data/ci/docker_hub', 'username'),
vault_secret('docker_password', 'infra/data/ci/docker_hub', 'password'),
]