2019-05-22 15:09:57 +00:00
|
|
|
local node_runtime(version, arch) = {
|
|
|
|
arch: arch,
|
|
|
|
containers: [
|
|
|
|
{
|
|
|
|
image: 'node:' + version,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
local task_build(version, arch) = {
|
|
|
|
name: 'build - node ' + version + ' ' + arch,
|
|
|
|
runtime: node_runtime(version, arch),
|
|
|
|
environment: {},
|
|
|
|
steps: [
|
|
|
|
{ type: 'clone' },
|
2019-07-11 08:49:56 +00:00
|
|
|
{ type: 'restore_cache', keys: ['cache-node' + version + '-sum-{{ md5sum "package.json" }}', 'cache-node' + version + '-date-'], dest_dir: './node_modules' },
|
2019-05-22 15:09:57 +00:00
|
|
|
{ type: 'run', command: 'npm install' },
|
|
|
|
{ type: 'run', command: 'npm run build' },
|
2019-07-11 08:49:56 +00:00
|
|
|
{ type: 'save_cache', key: 'cache-node' + version + '-sum-{{ md5sum "package.json" }}', contents: [{ source_dir: './node_modules' }] },
|
|
|
|
{ type: 'save_cache', key: 'cache-node' + version + '-date-{{ year }}-{{ month }}-{{ day }}', contents: [{ source_dir: './node_modules' }] },
|
2019-05-22 15:09:57 +00:00
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
{
|
|
|
|
runs: [
|
|
|
|
{
|
|
|
|
name: 'agola web build/test',
|
|
|
|
tasks: std.flattenArrays([
|
|
|
|
[
|
|
|
|
task_build(version, arch),
|
|
|
|
]
|
|
|
|
for version in ['11', '12']
|
|
|
|
for arch in ['amd64']
|
2019-07-11 08:49:56 +00:00
|
|
|
]) + [
|
|
|
|
{
|
|
|
|
name: 'checkout code and save to workspace',
|
|
|
|
runtime: {
|
|
|
|
arch: 'amd64',
|
|
|
|
containers: [
|
|
|
|
{
|
|
|
|
image: 'alpine/git',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
steps: [
|
|
|
|
{ type: 'clone' },
|
|
|
|
{ type: 'save_to_workspace', contents: [{ source_dir: '.', dest_dir: '.', paths: ['**'] }] },
|
|
|
|
],
|
|
|
|
depends: [],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'test build docker image',
|
|
|
|
runtime: {
|
|
|
|
arch: 'amd64',
|
|
|
|
containers: [
|
|
|
|
{
|
|
|
|
image: 'gcr.io/kaniko-project/executor:debug',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
shell: '/busybox/sh',
|
|
|
|
working_dir: '/workspace',
|
|
|
|
steps: [
|
|
|
|
{ type: 'restore_workspace', dest_dir: '.' },
|
|
|
|
{ type: 'run', command: '/kaniko/executor --no-push' },
|
|
|
|
],
|
|
|
|
depends: ['checkout code and save to workspace'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'build and push docker image',
|
|
|
|
runtime: {
|
|
|
|
arch: 'amd64',
|
|
|
|
containers: [
|
|
|
|
{
|
|
|
|
image: 'gcr.io/kaniko-project/executor:debug',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
environment: {
|
2022-03-04 08:34:07 +00:00
|
|
|
DOCKERAUTH: { from_variable: 'harbor-auth' },
|
|
|
|
DOCKERURL: { from_variable: 'harbor-url' },
|
2019-07-11 08:49:56 +00:00
|
|
|
},
|
|
|
|
shell: '/busybox/sh',
|
|
|
|
working_dir: '/workspace',
|
|
|
|
steps: [
|
|
|
|
{ type: 'restore_workspace', dest_dir: '.' },
|
|
|
|
{
|
|
|
|
type: 'run',
|
|
|
|
name: 'generate docker auth',
|
|
|
|
command: |||
|
|
|
|
cat << EOF > /kaniko/.docker/config.json
|
|
|
|
{
|
|
|
|
"auths": {
|
2022-03-04 08:48:21 +00:00
|
|
|
"harbor.tuxpa.in": { "auth": "cm9ib3QkdHV4Ok5uMHU3Z1Q1TU1GZE5kVjJFS0FnRlJlME0xMVBjeDJs" }
|
2019-07-11 08:49:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|||,
|
|
|
|
},
|
2022-03-04 08:17:39 +00:00
|
|
|
{ type: 'run', command: '/kaniko/executor --destination harbor.tuxpa.in/tux/agola-web:$AGOLA_GIT_TAG' },
|
2019-07-11 08:49:56 +00:00
|
|
|
],
|
|
|
|
depends: ['checkout code and save to workspace'],
|
|
|
|
when: {
|
|
|
|
tag: '#v.*#',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
2019-05-22 15:09:57 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
}
|