· 6 years ago · Jul 22, 2019, 05:30 AM
1apiVersion: argoproj.io/v1alpha1
2kind: Workflow
3metadata:
4 generateName: ci-runner-
5spec:
6 entrypoint: backend-ci
7 onExit: notify
8 serviceAccountName: argo-workflow
9 arguments:
10 parameters:
11 - name: github_url
12 - name: commit
13 - name: repo
14 - name: image_tag
15 - name: slack_channel
16 - name: endpoint
17 - name: src_path
18 templates:
19 - name: notify
20 container:
21 image: dictybase/slack-notify
22 args: ["-t", $(TOKEN),
23 "-c","{{workflow.parameters.slack_channel}}",
24 "-e","{{workflow.parameters.endpoint}}",
25 "-w", "{{workflow.name}}",
26 "-s","{{workflow.status}}",
27 "--log-level","info"
28 ]
29 env:
30 - name: TOKEN
31 valueFrom:
32 secretKeyRef:
33 name: slack-secret
34 key: oauth-token
35
36 - name: backend-ci
37 steps: # <--- ci pipeline steps
38 - - name: ref-parser
39 template: ref-parser
40 - - name: build-push # image build and push
41 template: build-push
42 arguments:
43 parameters:
44 - name: tag
45 value: "{{steps.ref-parser.outputs.parameters.tag}}"
46
47 # parse ref string from webhook response
48 - name: ref-parser
49 container:
50 image: alpine:3.7
51 args: ['echo "{{workflow.parameters.image_tag}}" | sed -E "s/refs\/(heads|tags)\///w ref.txt"']
52 command: [sh, -c]
53 outputs:
54 parameters:
55 - name: tag
56 valueFrom:
57 path: "ref.txt"
58
59 ## build in cluster docker image and pushes to docker hub
60 - name: build-push
61 inputs:
62 artifacts:
63 - name: source
64 path: "{{workflow.parameters.src_path}}"
65 git:
66 repo: "{{workflow.parameters.github_url}}"
67 revision: "{{workflow.parameters.commit}}"
68 parameters:
69 - name: tag
70 container:
71 image: gcr.io/kaniko-project/executor:latest
72 args: ["--dockerfile=build/package/Dockerfile",
73 "--context={{workflow.parameters.src_path}}",
74 "--destination=dictybase/{{workflow.parameters.repo}}:{{inputs.parameters.tag}}",
75 "--cache=true",
76 "--cache-repo=dictybase/{{workflow.parameters.repo}}-cache"
77 ]
78 volumeMounts:
79 - name: docker-secret
80 mountPath: /.docker
81 readOnly: true
82 volumes:
83 - name: docker-secret
84 secret:
85 secretName: docker-secret