Files
ansible-role-common/.drone.jsonnet
Aaron Guise b11417540b
Some checks failed
continuous-integration/drone/push Build was killed
Add notification on tag
2022-11-02 15:47:23 +13:00

114 lines
2.9 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: {},
},],
when:
{ event: {exclude: ['tag']},
},
};
local gen_release() =
{kind: 'pipeline',
type: 'docker',
name: 'Generate Release',
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}',
'tar -czf ../${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz ./*', // Create an archive of the role
'curl --user ${GITEA_USER}:${GITEA_TOKEN} --upload-file ../${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz https://${GITEA_URL}/api/packages/${GITEA_REPOUSER}/generic/ansible-role-common/${DRONE_TAG}/${DRONE_REPO_NAME}.${DRONE_TAG}.tar.gz',
],
when:
{ 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',
steps: [email_notification()],
when:
{ status: [ 'success', 'failure' ] ,
event: {exclude: ['tag']},
},
depends_on:
['Test on %(distro)s' % { distro: distro }
for distro in distros]
},
gen_release(),
{kind: 'pipeline',
type: 'docker',
name: 'Notify Tagged release',
steps: [email_notification()],
when:
{ status: [ 'success', 'failure' ] ,
event: {include: ['tag']},
},
depends_on:
['Generate Release']
},
]