You've already forked ansible-role-common
147 lines
3.7 KiB
Jsonnet
147 lines
3.7 KiB
Jsonnet
// Distros to Test on ;)
|
|
local distros = ['centos7',
|
|
'rockylinux8',
|
|
'debian10',
|
|
'debian11'];
|
|
|
|
/* Configuration of DIND */
|
|
local docker_service() =
|
|
{
|
|
name: 'docker',
|
|
image: 'docker:dind',
|
|
privileged: true,
|
|
volumes: [{ name: 'dockersock', path: '/var/run' },],
|
|
};
|
|
|
|
local email_notification() =
|
|
{
|
|
name: 'notify by email',
|
|
image: 'drillster/drone-email',
|
|
settings:
|
|
{ host:
|
|
{ from_secret: 'EMAIL_HOST' },
|
|
username:
|
|
{ from_secret: 'EMAIL_USER' },
|
|
password:
|
|
{ from_secret: 'EMAIL_PASS' },
|
|
from: 'drone@guise.net.nz'
|
|
}
|
|
};
|
|
|
|
local test_distro(distribution) =
|
|
{
|
|
name: 'Molecule test on %(distribution)s' % { distribution: distribution },
|
|
volumes: [{ name: 'dockersock', path: '/var/run' },],
|
|
pull: true,
|
|
image: 'guisea/ansible-molecule:alpine-latest',
|
|
commands: [
|
|
'sleep 10', // give docker enough time to start
|
|
'mkdir ${DRONE_REPO_NAME}',
|
|
'rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}',
|
|
'cd ${DRONE_REPO_NAME}',
|
|
'molecule test'
|
|
],
|
|
environment:
|
|
{ MOLECULE_DISTRO: '%(distribution)s' % { distribution: distribution }
|
|
},
|
|
};
|
|
|
|
local gen_pipeline(distro) =
|
|
{kind: 'pipeline',
|
|
type: 'docker',
|
|
name: 'Test on %(distro)s' % { distro: distro },
|
|
steps:
|
|
[test_distro(distro)],
|
|
services:
|
|
[docker_service()],
|
|
volumes:
|
|
[{
|
|
name: 'dockersock',
|
|
temp: {},
|
|
},],
|
|
trigger:
|
|
{ event: {exclude: ['tag'],},},
|
|
when:
|
|
{ event: {exclude: ['tag']},
|
|
},
|
|
};
|
|
|
|
local gen_release() =
|
|
{kind: 'pipeline',
|
|
type: 'docker',
|
|
image: 'guisea/ansible-molecule:alpine-latest',
|
|
name: 'Generate Release',
|
|
commands: [
|
|
'sleep 10', // give docker enough time to start
|
|
'env',
|
|
'mkdir ${DRONE_REPO_NAME}',
|
|
'rsync -a . ${DRONE_REPO_NAME} --exclude ${DRONE_REPO_NAME}',
|
|
'cd ${DRONE_REPO_NAME}',
|
|
'echo GITEA_USER=${USER}',
|
|
'apk update && apk add --no-cache curl',
|
|
'tar -czf ../${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz ./*', // Create an archive of the role
|
|
'curl --user $${USER}:$${TOKEN} --upload-file ../${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz https://$${URL}/api/packages/$${REPOUSER}/generic/ansible-role-common/${DRONE_TAG}/${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz',
|
|
],
|
|
environment:
|
|
{ USER: { from_secret: 'GITEA_USER' },
|
|
TOKEN: { from_secret: 'GITEA_TOKEN' },
|
|
REPOUSER: { from_secret: 'GITEA_REPOUSER'},
|
|
URL: { from_secret: 'GITEA_URL' },
|
|
},
|
|
when:
|
|
{ event: {include: ['tag']},
|
|
},
|
|
trigger:
|
|
{ event: {include: ['tag'],},},
|
|
};
|
|
|
|
local gen_pipeline_release() =
|
|
{kind: 'pipeline',
|
|
type: 'docker',
|
|
name: 'Generate release from tag',
|
|
steps:
|
|
[gen_release()],
|
|
when:
|
|
{ event: {include: ['tag']},
|
|
},
|
|
trigger:
|
|
{ event: {include: ['tag'],},},
|
|
};
|
|
|
|
// Generate the output
|
|
[
|
|
gen_pipeline('centos7'),
|
|
gen_pipeline('rockylinux8'),
|
|
gen_pipeline('debian10'),
|
|
gen_pipeline('debian11'),
|
|
{kind: 'pipeline',
|
|
type: 'docker',
|
|
name: 'Notify normal',
|
|
clone: {disable: true},
|
|
steps: [email_notification()],
|
|
trigger:
|
|
{ event: {exclude: ['tag'],},},
|
|
when:
|
|
{ status: [ 'success', 'failure' ] ,
|
|
event: {exclude: ['tag']},
|
|
},
|
|
depends_on:
|
|
['Test on %(distro)s' % { distro: distro }
|
|
for distro in distros]
|
|
},
|
|
gen_pipeline_release(),
|
|
{kind: 'pipeline',
|
|
type: 'docker',
|
|
clone: {disable: true},
|
|
name: 'Notify Tagged release',
|
|
steps: [email_notification()],
|
|
trigger:
|
|
{ event: {include: ['tag'],},},
|
|
when:
|
|
{ status: [ 'success', 'failure' ] ,
|
|
event: {include: ['tag']},
|
|
},
|
|
depends_on:
|
|
['Generate release from tag']
|
|
},
|
|
] |