Skip to content

Commit

Permalink
Merge pull request #1489 from owncloud/continuous_deployment
Browse files Browse the repository at this point in the history
continuous deployment
  • Loading branch information
wkloucek authored Feb 1, 2021
2 parents 85ee5de + f3404ab commit 17c4e9b
Show file tree
Hide file tree
Showing 8 changed files with 333 additions and 37 deletions.
127 changes: 91 additions & 36 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ def main(ctx):
build_release_helpers = [
changelog(ctx),
docs(ctx),
refreshDockerBadges(ctx),
updateDeployment(ctx),
refreshDockerBadges(ctx)
]

if ctx.build.event == "cron":
Expand All @@ -195,7 +194,7 @@ def main(ctx):
purgeBuildArtifactCache(ctx, 'ocis-binary-amd64'),
testPipelines(ctx)
)
]
] + example_deploys(ctx)

elif \
(ctx.build.event == "pull_request" and '[docs-only]' in ctx.build.title) \
Expand All @@ -214,6 +213,14 @@ def main(ctx):

pipelines = test_pipelines + build_release_pipelines + build_release_helpers


pipelines = \
pipelines + \
pipelinesDependsOn(
example_deploys(ctx),
pipelines
)

# always append notification step
pipelines.append(
pipelineDependsOn(
Expand Down Expand Up @@ -1266,39 +1273,6 @@ def makeGenerate(module):
}
]

def updateDeployment(ctx):
return {
'kind': 'pipeline',
'type': 'docker',
'name': 'updateDeployment',
'platform': {
'os': 'linux',
'arch': 'amd64',
},
'steps': [
{
'name': 'webhook',
'image': 'plugins/webhook:1',
'settings': {
'username': {
'from_secret': 'webhook_username',
},
'password': {
'from_secret': 'webhook_password',
},
'method': 'GET',
'urls': 'https://ocis.owncloud.works/hooks/update-ocis',
}
}
],
'depends_on': getPipelineNames(dockerReleases(ctx) + binaryReleases(ctx)),
'trigger': {
'ref': [
'refs/heads/master',
],
}
}

def notify(ctx):
return {
'kind': 'pipeline',
Expand Down Expand Up @@ -1460,6 +1434,87 @@ def build():
},
]

def example_deploys(ctx):
latest_configs = [
'cs3_users_ocis/latest.yml',
'ocis_keycloak/latest.yml',
'ocis_traefik/latest.yml',
]
released_configs = [
'cs3_users_ocis/released.yml',
'ocis_keycloak/released.yml',
'ocis_traefik/released.yml',
]

# if on master branch:
configs = latest_configs
rebuild = "false"

if ctx.build.event == "tag":
configs = released_configs
rebuild = 'false'

if ctx.build.event == "cron":
configs = latest_configs + released_configs
rebuild = 'true'

deploys = []
for config in configs:
deploys.append(deploy(ctx, config, rebuild))

return deploys

def deploy(ctx, config, rebuild):
return {
'kind': 'pipeline',
'type': 'docker',
'name': 'deploy_%s' % (config),
'platform': {
'os': 'linux',
'arch': 'amd64',
},
'steps': [
{
'name': 'clone continuous deployment playbook',
'image': 'alpine/git',
'commands': [
'cd deployments/continuous-deployment-config',
'git clone https://github.com/owncloud-devops/continuous-deployment.git',
]
},
{
'name': 'deploy',
'image': 'owncloudci/drone-ansible',
'failure': 'ignore',
'environment': {
'CONTINUOUS_DEPLOY_SERVERS_CONFIG': '../%s' % (config),
"REBUILD": '%s' % (rebuild),
'HCLOUD_API_TOKEN': {
'from_secret': 'hcloud_api_token'
},
'CLOUDFLARE_API_TOKEN': {
'from_secret': 'cloudflare_api_token'
}
},
'settings': {
'playbook': 'deployments/continuous-deployment-config/continuous-deployment/playbook-all.yml',
'galaxy': 'deployments/continuous-deployment-config/continuous-deployment/requirements.yml',
'requirements': 'deployments/continuous-deployment-config/continuous-deployment/py-requirements.txt',
'inventory': 'localhost',
'private_key': {
'from_secret': 'ssh_private_key'
}
}
},
],
'trigger': {
'ref': [
'refs/heads/master',
'refs/tags/v*',
],
},
}

def genericCache(name, action, mounts, cache_key):
rebuild = 'false'
restore = 'false'
Expand Down
39 changes: 39 additions & 0 deletions deployments/continuous-deployment-config/cs3_users_ocis/latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
- name: continuous-deployment-ocis-cs3-users-latest
server:
server_type: cx21
image: ubuntu-20.04
location: nbg1
initial_ssh_key_names:
- owncloud-ocis@drone.owncloud.com
labels:
owner: wkloucek
for: oCIS-continuous-deployment-examples
rebuild: $REBUILD

domains:
- "*.ocis-cs3-users.latest.owncloud.works"

vars:
docker_compose_projects:
- name: ocis
git_url: https://github.com/owncloud/ocis.git
ref: master
docker_compose_path: deployments/examples/cs3_users_ocis
env:
INSECURE: "false"
TRAEFIK_ACME_MAIL: wkloucek@owncloud.com
OCIS_DOCKER_TAG: latest
OCIS_DOMAIN: ocis.ocis-cs3-users.latest.owncloud.works
LDAP_MANAGER_DOMAIN: ldap.ocis-keycloak.released.owncloud.works
COMPOSE_FILE: docker-compose.yml:monitoring_tracing/docker-compose-additions.yml
- name: monitoring
git_url: https://github.com/owncloud-devops/monitoring-tracing-client.git
ref: master
env:
NETWORK_NAME: ocis-net
TELEMETRY_SERVE_DOMAIN: telemetry.ocis-traefik.latest.owncloud.works
JAEGER_COLLECTOR: jaeger-collector.infra.owncloud.works:443
TELEGRAF_SPECIFIC_CONFIG: ocis_single_container
OCIS_URL: ocis.ocis-cs3-users.latest.owncloud.works
OCIS_DEPLOYMENT_ID: continuous-deployment-ocis-cs3-users-latest
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
- name: continuous-deployment-ocis-cs3-users-released
server:
server_type: cx21
image: ubuntu-20.04
location: nbg1
initial_ssh_key_names:
- owncloud-ocis@drone.owncloud.com
labels:
owner: wkloucek
for: oCIS-continuous-deployment-examples
rebuild: $REBUILD

domains:
- "*.ocis-cs3-users.released.owncloud.works"

vars:
docker_compose_projects:
- name: ocis
git_url: https://github.com/owncloud/ocis.git
ref: master
docker_compose_path: deployments/examples/cs3_users_ocis
env:
INSECURE: "false"
TRAEFIK_ACME_MAIL: wkloucek@owncloud.com
OCIS_DOCKER_TAG: 1
OCIS_DOMAIN: ocis.ocis-cs3-users.released.owncloud.works
LDAP_MANAGER_DOMAIN: ldap.ocis-keycloak.released.owncloud.works
COMPOSE_FILE: docker-compose.yml:monitoring_tracing/docker-compose-additions.yml
- name: monitoring
git_url: https://github.com/owncloud-devops/monitoring-tracing-client.git
ref: master
env:
NETWORK_NAME: ocis-net
TELEMETRY_SERVE_DOMAIN: telemetry.ocis-traefik.released.owncloud.works
JAEGER_COLLECTOR: jaeger-collector.infra.owncloud.works:443
TELEGRAF_SPECIFIC_CONFIG: ocis_single_container
OCIS_URL: ocis.ocis-cs3-users.released.owncloud.works
OCIS_DEPLOYMENT_ID: continuous-deployment-ocis-cs3-users-released
39 changes: 39 additions & 0 deletions deployments/continuous-deployment-config/ocis_keycloak/latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
- name: continuous-deployment-ocis-keycloak-latest
server:
server_type: cx21
image: ubuntu-20.04
location: nbg1
initial_ssh_key_names:
- owncloud-ocis@drone.owncloud.com
labels:
owner: wkloucek
for: oCIS-continuous-deployment-examples
rebuild: $REBUILD

domains:
- "*.ocis-keycloak.latest.owncloud.works"

vars:
docker_compose_projects:
- name: ocis
git_url: https://github.com/owncloud/ocis.git
ref: master
docker_compose_path: deployments/examples/ocis_keycloak
env:
INSECURE: "false"
TRAEFIK_ACME_MAIL: wkloucek@owncloud.com
OCIS_DOCKER_TAG: latest
OCIS_DOMAIN: ocis.ocis-keycloak.latest.owncloud.works
KEYCLOAK_DOMAIN: keycloak.ocis-keycloak.latest.owncloud.works
COMPOSE_FILE: docker-compose.yml:monitoring_tracing/docker-compose-additions.yml
- name: monitoring
git_url: https://github.com/owncloud-devops/monitoring-tracing-client.git
ref: master
env:
NETWORK_NAME: ocis-net
TELEMETRY_SERVE_DOMAIN: telemetry.ocis-keycloak.latest.owncloud.works
JAEGER_COLLECTOR: jaeger-collector.infra.owncloud.works:443
TELEGRAF_SPECIFIC_CONFIG: ocis_single_container
OCIS_URL: ocis.ocis-keycloak.latest.owncloud.works
OCIS_DEPLOYMENT_ID: continuous-deployment-ocis-keycloak-latest
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
- name: continuous-deployment-ocis-keycloak-released
server:
server_type: cx21
image: ubuntu-20.04
location: nbg1
initial_ssh_key_names:
- owncloud-ocis@drone.owncloud.com
labels:
owner: wkloucek
for: oCIS-continuous-deployment-examples
rebuild: $REBUILD

domains:
- "*.ocis-keycloak.released.owncloud.works"

vars:
docker_compose_projects:
- name: ocis
git_url: https://github.com/owncloud/ocis.git
ref: master
docker_compose_path: deployments/examples/ocis_keycloak
env:
INSECURE: "false"
TRAEFIK_ACME_MAIL: wkloucek@owncloud.com
OCIS_DOCKER_TAG: 1
OCIS_DOMAIN: ocis.ocis-keycloak.released.owncloud.works
KEYCLOAK_DOMAIN: keycloak.ocis-keycloak.latest.owncloud.works
COMPOSE_FILE: docker-compose.yml:monitoring_tracing/docker-compose-additions.yml
- name: monitoring
git_url: https://github.com/owncloud-devops/monitoring-tracing-client.git
ref: master
env:
NETWORK_NAME: ocis-net
TELEMETRY_SERVE_DOMAIN: telemetry.ocis-keycloak.released.owncloud.works
JAEGER_COLLECTOR: jaeger-collector.infra.owncloud.works:443
TELEGRAF_SPECIFIC_CONFIG: ocis_single_container
OCIS_URL: ocis.ocis-keycloak.released.owncloud.works
OCIS_DEPLOYMENT_ID: continuous-deployment-ocis-keycloak-released
38 changes: 38 additions & 0 deletions deployments/continuous-deployment-config/ocis_traefik/latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
- name: continuous-deployment-ocis-traefik-latest
server:
server_type: cx21
image: ubuntu-20.04
location: nbg1
initial_ssh_key_names:
- owncloud-ocis@drone.owncloud.com
labels:
owner: wkloucek
for: oCIS-continuous-deployment-examples
rebuild: $REBUILD

domains:
- "*.ocis-traefik.latest.owncloud.works"

vars:
docker_compose_projects:
- name: ocis
git_url: https://github.com/owncloud/ocis.git
ref: master
docker_compose_path: deployments/examples/ocis_traefik
env:
INSECURE: "false"
TRAEFIK_ACME_MAIL: wkloucek@owncloud.com
OCIS_DOCKER_TAG: latest
OCIS_DOMAIN: ocis.ocis-traefik.latest.owncloud.works
COMPOSE_FILE: docker-compose.yml:monitoring_tracing/docker-compose-additions.yml
- name: monitoring
git_url: https://github.com/owncloud-devops/monitoring-tracing-client.git
ref: master
env:
NETWORK_NAME: ocis-net
TELEMETRY_SERVE_DOMAIN: telemetry.ocis-traefik.latest.owncloud.works
JAEGER_COLLECTOR: jaeger-collector.infra.owncloud.works:443
TELEGRAF_SPECIFIC_CONFIG: ocis_single_container
OCIS_URL: ocis.ocis-traefik.latest.owncloud.works
OCIS_DEPLOYMENT_ID: continuous-deployment-ocis-traefik-latest
38 changes: 38 additions & 0 deletions deployments/continuous-deployment-config/ocis_traefik/released.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
- name: continuous-deployment-ocis-traefik-released
server:
server_type: cx21
image: ubuntu-20.04
location: nbg1
initial_ssh_key_names:
- owncloud-ocis@drone.owncloud.com
labels:
owner: wkloucek
for: oCIS-continuous-deployment-examples
rebuild: $REBUILD

domains:
- "*.ocis-traefik.released.owncloud.works"

vars:
docker_compose_projects:
- name: ocis
git_url: https://github.com/owncloud/ocis.git
ref: master
docker_compose_path: deployments/examples/ocis_traefik
env:
INSECURE: "false"
TRAEFIK_ACME_MAIL: wkloucek@owncloud.com
OCIS_DOCKER_TAG: 1
OCIS_DOMAIN: ocis.ocis-traefik.released.owncloud.works
COMPOSE_FILE: docker-compose.yml:monitoring_tracing/docker-compose-additions.yml
- name: monitoring
git_url: https://github.com/owncloud-devops/monitoring-tracing-client.git
ref: master
env:
NETWORK_NAME: ocis-net
TELEMETRY_SERVE_DOMAIN: telemetry.ocis-traefik.released.owncloud.works
JAEGER_COLLECTOR: jaeger-collector.infra.owncloud.works:443
TELEGRAF_SPECIFIC_CONFIG: ocis_single_container
OCIS_URL: ocis.ocis-traefik.released.owncloud.works
OCIS_DEPLOYMENT_ID: continuous-deployment-ocis-traefik-released
Loading

0 comments on commit 17c4e9b

Please sign in to comment.