Skip to content

Commit

Permalink
Feature: trigger argo workflows on release (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
electron0zero authored Jan 21, 2022
1 parent e33fb14 commit ff9a1ef
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 71 deletions.
22 changes: 22 additions & 0 deletions .drone/drone.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local pipeline(name, steps=[]) = {
kind: 'pipeline',
type: 'docker',
name: name,
image_pull_secrets: ['docker_config_json'],
steps: [step('runner identification', ['echo $DRONE_RUNNER_NAME'], 'alpine')] + steps,
trigger+: {
ref+: [
Expand Down Expand Up @@ -140,11 +141,32 @@ local vault_secret(name, vault_path, key) = {
}
+ dependsOn(['docker push to docker.com'])
+ releaseOnly,

step('trigger argo workflow', [])
+ {
settings: {
namespace: 'synthetic-monitoring-cd',
token: { from_secret: 'argo_token' },
command: std.strReplace(|||
submit --from workflowtemplate/deploy-synthetic-monitoring-agent
--name deploy-synthetic-monitoring-agent-$(./scripts/version)
--parameter dockertag=$(./scripts/version)
--parameter commit=${DRONE_COMMIT}
--parameter commit_author=${DRONE_COMMIT_AUTHOR}
--parameter commit_link=${DRONE_COMMIT_LINK}
|||, '\n', ' '),
add_ci_labels: true,
},
image: 'us.gcr.io/kubernetes-dev/drone/plugins/argo-cli'
}
+ releaseOnly,

]),

vault_secret('docker_username', 'infra/data/ci/docker_hub', 'username'),
vault_secret('docker_password', 'infra/data/ci/docker_hub', 'password'),
vault_secret('gcs_key', 'infra/data/ci/gcp/synthetic-mon-publish-pkgs', 'key'),
vault_secret('gpg_priv_key', 'infra/data/ci/gcp/synthetic-mon-publish-pkgs', 'gpg_priv_key'),
vault_secret('docker_config_json', 'infra/data/ci/gcr-admin', '.dockerconfigjson'),
vault_secret('argo_token', 'infra/data/ci/argo-workflows/trigger-service-account', 'token'),
]
142 changes: 71 additions & 71 deletions .drone/drone.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,56 @@
---
image_pull_secrets:
- docker_config_json
kind: pipeline
type: docker
name: build

platform:
os: linux
arch: amd64

steps:
- name: runner identification
image: alpine
commands:
- commands:
- echo $DRONE_RUNNER_NAME

- name: deps
image: golang:1.17
commands:
image: alpine
name: runner identification
- commands:
- make deps
- ./scripts/enforce-clean
depends_on:
- runner identification

- name: lint
image: golang:1.17
commands:
name: deps
- commands:
- make lint
depends_on:
- runner identification

- name: test
image: golang:1.17
commands:
name: lint
- commands:
- make test
depends_on:
- lint

- name: build
image: golang:1.17
commands:
name: test
- commands:
- git fetch origin --tags
- git status --porcelain --untracked-files=no
- git diff --no-ext-diff --quiet
- ./scripts/version
- "{ echo -n latest, ; ./scripts/version ; } > .tags"
- '{ echo -n latest, ; ./scripts/version ; } > .tags'
- make build
depends_on:
- test

- name: docker build
image: golang:1.17
name: build
- commands: []
depends_on:
- build
image: plugins/docker
name: docker build
settings:
dry_run: true
dry_run: "true"
repo: grafana/synthetic-monitoring-agent
- commands: []
depends_on:
- build

- name: docker push to docker.com
- docker build
image: plugins/docker
name: docker push to docker.com
settings:
password:
from_secret: docker_password
Expand All @@ -66,110 +60,116 @@ steps:
when:
ref:
- refs/tags/v*.*.*
- commands: []
depends_on:
- docker build

- name: docker push to gcr.io (dev)
image: plugins/docker
name: docker push to gcr.io (dev)
settings:
config:
from_secret: docker_config_json
repo: us.gcr.io/kubernetes-dev/synthetic-monitoring-agent
when:
ref:
- refs/heads/main
- commands: []
depends_on:
- docker build

- name: docker push to gcr.io (release)
image: plugins/docker
name: docker push to gcr.io (release)
settings:
config:
from_secret: docker_config_json
repo: us.gcr.io/kubernetes-dev/synthetic-monitoring-agent
when:
ref:
- refs/tags/v*.*.*
- commands:
- make package
depends_on:
- docker build

- name: package
image: golang:1.17
commands:
- make package
name: package
when:
event:
- pull_request
depends_on:
- docker build

- name: publish packages
image: golang:1.17
commands:
- commands:
- export GCS_KEY_DIR=$(pwd)/keys
- mkdir -p $GCS_KEY_DIR
- echo "$GCS_KEY" | base64 -d > $GCS_KEY_DIR/gcs-key.json
- make publish-packages
depends_on:
- docker push to docker.com
environment:
GCS_KEY:
from_secret: gcs_key
GPG_PRIV_KEY:
from_secret: gpg_priv_key
PUBLISH_PROD_PKGS: 1
PUBLISH_PROD_PKGS: "1"
image: golang:1.17
name: publish packages
when:
ref:
- refs/tags/v*.*.*
- commands: []
image: us.gcr.io/kubernetes-dev/drone/plugins/argo-cli
name: trigger argo workflow
settings:
add_ci_labels: true
command: 'submit --from workflowtemplate/deploy-synthetic-monitoring-agent --name
deploy-synthetic-monitoring-agent-$(./scripts/version) --parameter dockertag=$(./scripts/version)
--parameter commit=${DRONE_COMMIT} --parameter commit_author=${DRONE_COMMIT_AUTHOR}
--parameter commit_link=${DRONE_COMMIT_LINK} '
namespace: synthetic-monitoring-cd
token:
from_secret: argo_token
when:
ref:
- refs/tags/v*.*.*
depends_on:
- docker push to docker.com

trigger:
ref:
- refs/heads/main
- refs/pull/**
- refs/tags/v*.*.*

type: docker
---
get:
name: username
path: infra/data/ci/docker_hub
kind: secret
name: docker_username

---
get:
name: password
path: infra/data/ci/docker_hub
name: username

---
kind: secret
name: docker_password

get:
path: infra/data/ci/docker_hub
name: password

---
get:
name: key
path: infra/data/ci/gcp/synthetic-mon-publish-pkgs
kind: secret
name: gcs_key

---
get:
name: gpg_priv_key
path: infra/data/ci/gcp/synthetic-mon-publish-pkgs
name: key

---
kind: secret
name: gpg_priv_key

get:
path: infra/data/ci/gcp/synthetic-mon-publish-pkgs
name: gpg_priv_key

---
get:
name: .dockerconfigjson
path: infra/data/ci/gcr-admin
kind: secret
name: docker_config_json

---
get:
path: infra/data/ci/gcr-admin
name: .dockerconfigjson

name: token
path: infra/data/ci/argo-workflows/trigger-service-account
kind: secret
name: argo_token
---
kind: signature
hmac: 1b78d42b87ceeb1ae9d086bcaf9f9f661be6e001acb6685679646d5737f36cda
hmac: 0b335d98e90e8f2d17bb483e759e54bdd53dcfb678afdf7a5132efeef5cfeac1

...

0 comments on commit ff9a1ef

Please sign in to comment.