0
0
mirror of https://github.com/thegeeklab/wp-ansible.git synced 2024-11-13 22:50:40 +00:00
wp-ansible/.drone.star

359 lines
9.9 KiB
Plaintext
Raw Normal View History

2021-01-26 11:00:05 +00:00
def main(ctx):
before = test(ctx)
2021-01-26 11:00:05 +00:00
stages = [
docker(ctx, "amd64"),
docker(ctx, "arm64"),
build(ctx),
2021-01-26 11:00:05 +00:00
]
after = manifest(ctx) + pushrm(ctx)
2021-01-26 11:00:05 +00:00
for b in before:
for s in stages:
s["depends_on"].append(b["name"])
for s in stages:
for a in after:
a["depends_on"].append(s["name"])
return before + stages + after
def test(ctx):
2021-01-26 11:00:05 +00:00
return [{
"kind": "pipeline",
"type": "docker",
"name": "test",
2021-01-26 11:00:05 +00:00
"platform": {
"os": "linux",
"arch": "amd64",
},
"steps": [
{
"name": "deps",
"image": "docker.io/golang:1.20",
2021-01-26 11:00:05 +00:00
"commands": [
"make deps",
2021-01-26 11:00:05 +00:00
],
2021-01-26 11:28:47 +00:00
"volumes": [
{
"name": "godeps",
2021-01-26 11:28:47 +00:00
"path": "/go",
},
],
2021-01-26 11:00:05 +00:00
},
{
"name": "generate",
"image": "docker.io/golang:1.20",
2021-01-26 11:00:05 +00:00
"commands": [
"make generate",
2021-01-26 11:00:05 +00:00
],
2021-01-26 11:28:47 +00:00
"volumes": [
{
"name": "godeps",
2021-01-26 11:28:47 +00:00
"path": "/go",
},
],
2021-01-26 11:00:05 +00:00
},
{
"name": "lint",
"image": "docker.io/golang:1.20",
2021-01-26 11:00:05 +00:00
"commands": [
"make lint",
2021-01-26 11:00:05 +00:00
],
2021-01-26 11:28:47 +00:00
"volumes": [
{
"name": "godeps",
2021-01-26 11:28:47 +00:00
"path": "/go",
},
],
2021-01-26 11:00:05 +00:00
},
{
"name": "test",
"image": "docker.io/golang:1.20",
2021-01-26 11:00:05 +00:00
"commands": [
"make test",
2021-01-26 11:00:05 +00:00
],
2021-01-26 11:28:47 +00:00
"volumes": [
{
"name": "godeps",
2021-01-26 11:28:47 +00:00
"path": "/go",
},
],
},
],
"volumes": [
{
"name": "godeps",
2021-01-26 11:28:47 +00:00
"temp": {},
2021-01-26 11:00:05 +00:00
},
],
"trigger": {
"ref": [
"refs/heads/master",
"refs/tags/**",
"refs/pull/**",
],
},
}]
def build(ctx):
return {
"kind": "pipeline",
"type": "docker",
"name": "build-binaries",
"platform": {
"os": "linux",
"arch": "amd64",
2021-01-26 11:00:05 +00:00
},
"steps": [
{
"name": "generate",
"image": "docker.io/golang:1.20",
"pull": "always",
"commands": [
"make generate",
],
"volumes": [
{
"name": "godeps",
"path": "/go",
},
],
2021-01-26 11:00:05 +00:00
},
{
"name": "build",
"image": "docker.io/techknowlogick/xgo:go-1.20.x",
"pull": "always",
"commands": [
"ln -s /drone/src /source",
"make release",
],
"volumes": [
{
"name": "godeps",
"path": "/go",
},
],
},
{
"name": "executable",
"image": "docker.io/golang:1.20",
"pull": "always",
"commands": [
"$(find dist/ -executable -type f -iname drone-ansible-linux-amd64) --help",
],
},
{
"name": "changelog",
"image": "quay.io/thegeeklab/git-chglog",
"commands": [
"git fetch -tq",
"git-chglog --no-color --no-emoji %s" % (ctx.build.ref.replace("refs/tags/", "") if ctx.build.event == "tag" else "--next-tag unreleased unreleased"),
"git-chglog --no-color --no-emoji -o CHANGELOG.md %s" % (ctx.build.ref.replace("refs/tags/", "") if ctx.build.event == "tag" else "--next-tag unreleased unreleased"),
],
},
{
"name": "publish",
"image": "docker.io/plugins/github-release",
"pull": "always",
"settings": {
"api_key": {
"from_secret": "github_token",
},
"files": [
"dist/*",
],
"note": "CHANGELOG.md",
"title": ctx.build.ref.replace("refs/tags/", ""),
"overwrite": True,
2021-01-26 11:00:05 +00:00
},
"when": {
"ref": [
"refs/tags/**",
],
2021-01-26 11:00:05 +00:00
},
2021-02-09 09:45:07 +00:00
},
],
"volumes": [
{
"name": "godeps",
"temp": {},
2021-01-26 11:00:05 +00:00
},
],
"depends_on": [
"test",
],
"trigger": {
"ref": [
"refs/heads/master",
"refs/tags/**",
"refs/pull/**",
],
},
}
2021-01-26 11:00:05 +00:00
def docker(ctx, arch):
2021-01-26 11:00:05 +00:00
return {
"kind": "pipeline",
"type": "docker",
2021-02-09 09:45:07 +00:00
"name": "build-%s" % (arch),
2021-01-26 11:00:05 +00:00
"platform": {
"os": "linux",
"arch": arch,
},
"steps": [
{
"name": "generate",
"image": "docker.io/golang:1.20",
"pull": "always",
"commands": [
"make generate",
],
"volumes": [
{
"name": "godeps",
"path": "/go",
},
],
},
{
"name": "build",
"image": "docker.io/golang:1.20",
"pull": "always",
"commands": [
"make build",
],
"volumes": [
{
"name": "godeps",
"path": "/go",
},
],
},
{
"name": "dryrun",
"image": "docker.io/plugins/docker:20",
"pull": "always",
"settings": {
"dry_run": True,
"dockerfile": "docker/Dockerfile.%s" % (arch),
"repo": "owncloudci/%s" % (ctx.repo.name),
"tags": "latest",
},
"when": {
"ref": {
"include": [
"refs/pull/**",
],
},
},
},
{
"name": "docker",
"image": "docker.io/plugins/docker:20",
"pull": "always",
"settings": {
"username": {
2022-04-25 14:15:55 +00:00
"from_secret": "docker_username",
},
"password": {
2022-04-25 14:15:55 +00:00
"from_secret": "docker_password",
},
"auto_tag": True,
"auto_tag_suffix": "%s" % (arch),
"dockerfile": "docker/Dockerfile.%s" % (arch),
"repo": "owncloudci/%s" % (ctx.repo.name),
},
"when": {
"ref": {
"exclude": [
"refs/pull/**",
],
},
},
},
],
"volumes": [
{
"name": "godeps",
"temp": {},
},
],
"depends_on": [
"test",
],
2021-01-26 11:00:05 +00:00
"trigger": {
"ref": [
"refs/heads/master",
"refs/tags/**",
"refs/pull/**",
],
},
}
def manifest(ctx):
return [{
"kind": "pipeline",
"type": "docker",
"name": "manifest",
"steps": [
{
"name": "manifest",
"image": "docker.io/plugins/manifest",
2021-01-26 11:00:05 +00:00
"settings": {
"auto_tag": "true",
"username": {
"from_secret": "docker_username",
},
"password": {
"from_secret": "docker_password",
},
"spec": "docker/manifest.tmpl",
"ignore_missing": "true",
},
},
],
"depends_on": [],
"trigger": {
"ref": [
"refs/heads/master",
"refs/tags/**",
],
},
}]
2021-01-26 13:06:02 +00:00
def pushrm(ctx):
return [{
"kind": "pipeline",
"type": "docker",
"name": "pushrm",
"steps": [
{
"name": "pushrm",
"image": "docker.io/chko/docker-pushrm:1",
"environment": {
"DOCKER_PASS": {
"from_secret": "docker_password",
},
"DOCKER_USER": {
"from_secret": "docker_username",
},
"PUSHRM_FILE": "README.md",
"PUSHRM_SHORT": "Drone plugin to provision infrastructure with Ansible",
"PUSHRM_TARGET": "owncloudci/%s" % (ctx.repo.name),
2021-01-26 13:06:02 +00:00
},
2021-01-26 12:29:26 +00:00
},
],
"depends_on": [
"manifest",
2021-01-26 11:00:05 +00:00
],
"trigger": {
"ref": [
"refs/heads/master",
"refs/tags/**",
],
"status": ["success"],
},
}]