diff --git a/.drone.yml b/.drone.yml index 7d5d1de..7593547 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,7 +1,5 @@ kind: pipeline name: ssh-test -clone: - depth: 1 steps: - name: ssh image: appleboy/drone-ssh @@ -12,14 +10,34 @@ steps: from_secret: ssh_key script: - cd /home/core/staging && ls - when: - branch: - - master +--- +kind: pipeline +name: call-self +steps: + - name: regenrate + image: 'node:12-alpine' + commands: + - yarn install + - yarn generate + - name: push-or-fail + image: appleboy/drone-git-push + settings: + remote_name: origin + branch: '${DRONE_SOURCE_BRANCH}' + key: + from_secret: push_ssh_key + commit: true + commit_message: '[SKIP CI] Automatically updating .drone.yml' +trigger: + branch: + - master + event: + - pull_request --- kind: pipeline name: backend-auth clone: - depth: 1 + depth: 32 steps: - name: submodule image: plugins/git @@ -27,19 +45,14 @@ steps: recursive: true submodule_override: backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' - backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' backend-core: 'https://git.makerforce.io/beep/backend-core.git' backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' backend-login: 'https://git.makerforce.io/beep/backend-login.git' - backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' - backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' - backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-permissions: 'https://git.makerforce.io/beep/backend-permissions.git' + backend-pictures: 'https://git.makerforce.io/beep/backend-pictures.git' backend-store: 'https://git.makerforce.io/beep/backend-store.git' - backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' - when: - branch: - - master + backend-webrtc: 'https://git.makerforce.io/beep/backend-webrtc.git' - name: docker image: plugins/docker settings: @@ -52,54 +65,19 @@ steps: from_secret: docker_username password: from_secret: docker_password - when: - branch: - - master ---- -kind: pipeline -name: backend-bite -clone: - depth: 1 -steps: - - name: submodule - image: plugins/git - settings: - recursive: true - submodule_override: - backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' - backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' - backend-core: 'https://git.makerforce.io/beep/backend-core.git' - backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' - backend-login: 'https://git.makerforce.io/beep/backend-login.git' - backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' - backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' - backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' - backend-store: 'https://git.makerforce.io/beep/backend-store.git' - backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' - backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' - when: - branch: - - master - - name: docker - image: plugins/docker - settings: - registry: registry.makerforce.io - repo: registry.makerforce.io/beep/backend-bite - context: backend-bite - dockerfile: backend-bite/Dockerfile - auto_tag: true - username: - from_secret: docker_username - password: - from_secret: docker_password - when: - branch: - - master +trigger: + branch: + - master + event: + - push + - tag + - promote + - rollback --- kind: pipeline name: backend-core clone: - depth: 1 + depth: 32 steps: - name: submodule image: plugins/git @@ -107,19 +85,14 @@ steps: recursive: true submodule_override: backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' - backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' backend-core: 'https://git.makerforce.io/beep/backend-core.git' backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' backend-login: 'https://git.makerforce.io/beep/backend-login.git' - backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' - backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' - backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-permissions: 'https://git.makerforce.io/beep/backend-permissions.git' + backend-pictures: 'https://git.makerforce.io/beep/backend-pictures.git' backend-store: 'https://git.makerforce.io/beep/backend-store.git' - backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' - when: - branch: - - master + backend-webrtc: 'https://git.makerforce.io/beep/backend-webrtc.git' - name: docker image: plugins/docker settings: @@ -132,14 +105,19 @@ steps: from_secret: docker_username password: from_secret: docker_password - when: - branch: - - master +trigger: + branch: + - master + event: + - push + - tag + - promote + - rollback --- kind: pipeline name: backend-heartbeat clone: - depth: 1 + depth: 32 steps: - name: submodule image: plugins/git @@ -147,19 +125,14 @@ steps: recursive: true submodule_override: backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' - backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' backend-core: 'https://git.makerforce.io/beep/backend-core.git' backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' backend-login: 'https://git.makerforce.io/beep/backend-login.git' - backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' - backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' - backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-permissions: 'https://git.makerforce.io/beep/backend-permissions.git' + backend-pictures: 'https://git.makerforce.io/beep/backend-pictures.git' backend-store: 'https://git.makerforce.io/beep/backend-store.git' - backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' - when: - branch: - - master + backend-webrtc: 'https://git.makerforce.io/beep/backend-webrtc.git' - name: docker image: plugins/docker settings: @@ -172,14 +145,19 @@ steps: from_secret: docker_username password: from_secret: docker_password - when: - branch: - - master +trigger: + branch: + - master + event: + - push + - tag + - promote + - rollback --- kind: pipeline name: backend-login clone: - depth: 1 + depth: 32 steps: - name: submodule image: plugins/git @@ -187,19 +165,14 @@ steps: recursive: true submodule_override: backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' - backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' backend-core: 'https://git.makerforce.io/beep/backend-core.git' backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' backend-login: 'https://git.makerforce.io/beep/backend-login.git' - backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' - backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' - backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-permissions: 'https://git.makerforce.io/beep/backend-permissions.git' + backend-pictures: 'https://git.makerforce.io/beep/backend-pictures.git' backend-store: 'https://git.makerforce.io/beep/backend-store.git' - backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' - when: - branch: - - master + backend-webrtc: 'https://git.makerforce.io/beep/backend-webrtc.git' - name: docker image: plugins/docker settings: @@ -212,14 +185,19 @@ steps: from_secret: docker_username password: from_secret: docker_password - when: - branch: - - master +trigger: + branch: + - master + event: + - push + - tag + - promote + - rollback --- kind: pipeline -name: backend-publish +name: backend-permissions clone: - depth: 1 + depth: 32 steps: - name: submodule image: plugins/git @@ -227,39 +205,39 @@ steps: recursive: true submodule_override: backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' - backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' backend-core: 'https://git.makerforce.io/beep/backend-core.git' backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' backend-login: 'https://git.makerforce.io/beep/backend-login.git' - backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' - backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' - backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-permissions: 'https://git.makerforce.io/beep/backend-permissions.git' + backend-pictures: 'https://git.makerforce.io/beep/backend-pictures.git' backend-store: 'https://git.makerforce.io/beep/backend-store.git' - backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' - when: - branch: - - master + backend-webrtc: 'https://git.makerforce.io/beep/backend-webrtc.git' - name: docker image: plugins/docker settings: registry: registry.makerforce.io - repo: registry.makerforce.io/beep/backend-publish - context: backend-publish - dockerfile: backend-publish/Dockerfile + repo: registry.makerforce.io/beep/backend-permissions + context: backend-permissions + dockerfile: backend-permissions/Dockerfile auto_tag: true username: from_secret: docker_username password: from_secret: docker_password - when: - branch: - - master +trigger: + branch: + - master + event: + - push + - tag + - promote + - rollback --- kind: pipeline -name: backend-signal +name: backend-pictures clone: - depth: 1 + depth: 32 steps: - name: submodule image: plugins/git @@ -267,39 +245,39 @@ steps: recursive: true submodule_override: backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' - backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' backend-core: 'https://git.makerforce.io/beep/backend-core.git' backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' backend-login: 'https://git.makerforce.io/beep/backend-login.git' - backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' - backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' - backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-permissions: 'https://git.makerforce.io/beep/backend-permissions.git' + backend-pictures: 'https://git.makerforce.io/beep/backend-pictures.git' backend-store: 'https://git.makerforce.io/beep/backend-store.git' - backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' - when: - branch: - - master + backend-webrtc: 'https://git.makerforce.io/beep/backend-webrtc.git' - name: docker image: plugins/docker settings: registry: registry.makerforce.io - repo: registry.makerforce.io/beep/backend-signal - context: backend-signal - dockerfile: backend-signal/Dockerfile + repo: registry.makerforce.io/beep/backend-pictures + context: backend-pictures + dockerfile: backend-pictures/Dockerfile auto_tag: true username: from_secret: docker_username password: from_secret: docker_password - when: - branch: - - master +trigger: + branch: + - master + event: + - push + - tag + - promote + - rollback --- kind: pipeline name: backend-store clone: - depth: 1 + depth: 32 steps: - name: submodule image: plugins/git @@ -307,19 +285,14 @@ steps: recursive: true submodule_override: backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' - backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' backend-core: 'https://git.makerforce.io/beep/backend-core.git' backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' backend-login: 'https://git.makerforce.io/beep/backend-login.git' - backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' - backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' - backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-permissions: 'https://git.makerforce.io/beep/backend-permissions.git' + backend-pictures: 'https://git.makerforce.io/beep/backend-pictures.git' backend-store: 'https://git.makerforce.io/beep/backend-store.git' - backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' - when: - branch: - - master + backend-webrtc: 'https://git.makerforce.io/beep/backend-webrtc.git' - name: docker image: plugins/docker settings: @@ -332,54 +305,19 @@ steps: from_secret: docker_username password: from_secret: docker_password - when: - branch: - - master ---- -kind: pipeline -name: backend-subscribe -clone: - depth: 1 -steps: - - name: submodule - image: plugins/git - settings: - recursive: true - submodule_override: - backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' - backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' - backend-core: 'https://git.makerforce.io/beep/backend-core.git' - backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' - backend-login: 'https://git.makerforce.io/beep/backend-login.git' - backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' - backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' - backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' - backend-store: 'https://git.makerforce.io/beep/backend-store.git' - backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' - backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' - when: - branch: - - master - - name: docker - image: plugins/docker - settings: - registry: registry.makerforce.io - repo: registry.makerforce.io/beep/backend-subscribe - context: backend-subscribe - dockerfile: backend-subscribe/Dockerfile - auto_tag: true - username: - from_secret: docker_username - password: - from_secret: docker_password - when: - branch: - - master +trigger: + branch: + - master + event: + - push + - tag + - promote + - rollback --- kind: pipeline name: backend-transcription clone: - depth: 1 + depth: 32 steps: - name: submodule image: plugins/git @@ -387,19 +325,14 @@ steps: recursive: true submodule_override: backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' - backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' backend-core: 'https://git.makerforce.io/beep/backend-core.git' backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' backend-login: 'https://git.makerforce.io/beep/backend-login.git' - backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' - backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' - backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-permissions: 'https://git.makerforce.io/beep/backend-permissions.git' + backend-pictures: 'https://git.makerforce.io/beep/backend-pictures.git' backend-store: 'https://git.makerforce.io/beep/backend-store.git' - backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' - when: - branch: - - master + backend-webrtc: 'https://git.makerforce.io/beep/backend-webrtc.git' - name: docker image: plugins/docker settings: @@ -412,14 +345,19 @@ steps: from_secret: docker_username password: from_secret: docker_password - when: - branch: - - master +trigger: + branch: + - master + event: + - push + - tag + - promote + - rollback --- kind: pipeline -name: deploy +name: backend-webrtc clone: - depth: 1 + depth: 32 steps: - name: submodule image: plugins/git @@ -427,19 +365,52 @@ steps: recursive: true submodule_override: backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' - backend-bite: 'https://git.makerforce.io/beep/backend-bite.git' backend-core: 'https://git.makerforce.io/beep/backend-core.git' backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' backend-login: 'https://git.makerforce.io/beep/backend-login.git' - backend-protobuf: 'https://git.makerforce.io/beep/backend-protobuf.git' - backend-publish: 'https://git.makerforce.io/beep/backend-publish.git' - backend-signal: 'https://git.makerforce.io/beep/backend-signal.git' + backend-permissions: 'https://git.makerforce.io/beep/backend-permissions.git' + backend-pictures: 'https://git.makerforce.io/beep/backend-pictures.git' backend-store: 'https://git.makerforce.io/beep/backend-store.git' - backend-subscribe: 'https://git.makerforce.io/beep/backend-subscribe.git' backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' - when: - branch: - - master + backend-webrtc: 'https://git.makerforce.io/beep/backend-webrtc.git' + - name: docker + image: plugins/docker + settings: + registry: registry.makerforce.io + repo: registry.makerforce.io/beep/backend-webrtc + context: backend-webrtc + dockerfile: backend-webrtc/Dockerfile + auto_tag: true + username: + from_secret: docker_username + password: + from_secret: docker_password +trigger: + branch: + - master + event: + - push + - tag + - promote + - rollback +--- +kind: pipeline +name: deploy +steps: + - name: submodule + image: plugins/git + settings: + recursive: true + submodule_override: + backend-auth: 'https://git.makerforce.io/beep/backend-auth.git' + backend-core: 'https://git.makerforce.io/beep/backend-core.git' + backend-heartbeat: 'https://git.makerforce.io/beep/backend-heartbeat.git' + backend-login: 'https://git.makerforce.io/beep/backend-login.git' + backend-permissions: 'https://git.makerforce.io/beep/backend-permissions.git' + backend-pictures: 'https://git.makerforce.io/beep/backend-pictures.git' + backend-store: 'https://git.makerforce.io/beep/backend-store.git' + backend-transcription: 'https://git.makerforce.io/beep/backend-transcription.git' + backend-webrtc: 'https://git.makerforce.io/beep/backend-webrtc.git' - name: copy-docker-compose image: appleboy/drone-scp settings: @@ -451,9 +422,6 @@ steps: - docker-compose.staging.yml - traefik.staging.toml target: /home/core/staging - when: - branch: - - master - name: copy-migrations image: appleboy/drone-scp settings: @@ -464,9 +432,6 @@ steps: source: - backend-core/postgres/* target: /home/core/staging - when: - branch: - - master - name: docker-compose-up image: appleboy/drone-ssh settings: @@ -481,25 +446,26 @@ steps: - >- cd /home/core/staging && /home/core/docker-compose -f docker-compose.staging.yml up -d - when: - branch: - - master - name: slack image: plugins/slack settings: webhook: from_secret: slack_webhook_beep - when: - branch: - - master +trigger: + branch: + - master + event: + - push + - tag + - promote + - rollback depends_on: - backend-auth - - backend-bite - backend-core - backend-heartbeat - backend-login - - backend-publish - - backend-signal + - backend-permissions + - backend-pictures - backend-store - - backend-subscribe - backend-transcription + - backend-webrtc diff --git a/drone_gen.js b/drone_gen.js index 81e3529..ed3db31 100644 --- a/drone_gen.js +++ b/drone_gen.js @@ -20,7 +20,7 @@ const yamls = dockers.map(f => ({ kind: 'pipeline', name: f, clone: { - depth: 1, + depth: 32, }, steps: [ { @@ -30,9 +30,6 @@ const yamls = dockers.map(f => ({ recursive: true, submodule_override, }, - when: { - branch: ['master'], - }, }, { name: 'docker', @@ -50,19 +47,17 @@ const yamls = dockers.map(f => ({ from_secret: 'docker_password', }, }, - when: { - branch: ['master'], - }, }, ], + trigger: { + branch: ["master"], + event: ["push", "tag", "promote", "rollback"], + }, })) const sshTest = { kind: 'pipeline', name: 'ssh-test', - clone: { - depth: 1, - }, steps: [ { name: 'ssh', @@ -77,19 +72,45 @@ const sshTest = { 'cd /home/core/staging && ls' ], }, - when: { - branch: ['master'], + }, + ], +}; + +const callSelf = { + kind: 'pipeline', + name: 'call-self', + steps: [ + { + name: 'regenrate', + image: 'node:12-alpine', + commands: [ + 'yarn install', + 'yarn generate', + ], + }, + { + name: 'push-or-fail', + image: 'appleboy/drone-git-push', + settings: { + remote_name: 'origin', + branch: '${DRONE_SOURCE_BRANCH}', + key: { + from_secret: 'push_ssh_key', + }, + commit: true, + commit_message: '[SKIP CI] Automatically updating .drone.yml', }, }, ], + trigger: { + branch: ["master"], + event: ["pull_request"], + }, }; const deploy = { kind: 'pipeline', name: 'deploy', - clone: { - depth: 1, - }, steps: [ { name: 'submodule', @@ -98,9 +119,6 @@ const deploy = { recursive: true, submodule_override, }, - when: { - branch: ['master'], - }, }, { name: 'copy-docker-compose', @@ -117,9 +135,6 @@ const deploy = { ], target: '/home/core/staging', }, - when: { - branch: ['master'], - }, }, { name: 'copy-migrations', @@ -135,9 +150,6 @@ const deploy = { ], target: '/home/core/staging', }, - when: { - branch: ['master'], - }, }, { name: 'docker-compose-up', @@ -153,9 +165,6 @@ const deploy = { 'cd /home/core/staging && /home/core/docker-compose -f docker-compose.staging.yml up -d', ], }, - when: { - branch: ['master'], - }, }, { name: 'slack', @@ -165,15 +174,16 @@ const deploy = { from_secret: 'slack_webhook_beep', }, }, - when: { - branch: ['master'], - }, }, ], + trigger: { + branch: ["master"], + event: ["push", "tag", "promote", "rollback"], + }, depends_on: dockers, }; -const droneyml = [].concat(sshTest).concat(yamls).concat(deploy).map(yaml.safeDump).join('---\n'); +const droneyml = [].concat(sshTest).concat(callSelf).concat(yamls).concat(deploy).map(yaml.safeDump).join('---\n'); fs.writeFileSync(path.join(cwd, '.drone.yml'), droneyml); console.log('Written to .drone.yml');