· 6 years ago · Jul 22, 2019, 01:20 PM
1apiVersion: argoproj.io/v1alpha1
2kind: Workflow
3metadata:
4 generateName: frontend-ci-runner-
5spec:
6 entrypoint: frontend-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 - name: frontend-tag
19 - name: builder-image
20 value: gcr.io/kaniko-project/executor
21 - name: builder-tag
22 value: latest
23 templates:
24 - name: notify
25 container:
26 image: dictybase/slack-notify
27 args: ["-t", $(TOKEN),
28 "-c","{{workflow.parameters.slack-channel}}",
29 "-e","{{workflow.parameters.endpoint}}",
30 "-w", "{{workflow.name}}",
31 "-s","{{workflow.status}}",
32 "--log-level","info"
33 ]
34 env:
35 - name: TOKEN
36 valueFrom:
37 secretKeyRef:
38 name: slack-secret
39 key: oauth-token
40
41 - name: frontend-ci
42 steps:
43 - - name: ref-parser
44 template: ref-parser
45 - - name: unit-test
46 template: unit-test
47 - - name: build
48 template: build
49 arguments:
50 artifacts:
51 - name: source
52 from: "{{steps.unit-test.outputs.artifacts.source}}"
53 - - name: image-build-push
54 template: image-build-push
55 arguments:
56 artifacts:
57 - name: source
58 from: "{{steps.build.outputs.artifacts.source}}"
59 parameters:
60 - name: tag
61 value: "{{steps.ref-parser.outputs.parameters.tag}}"
62
63 # parse ref string from webhook response
64 - name: ref-parser
65 container:
66 image: alpine:3.7
67 args: ['echo "{{workflow.parameters.image-tag}}" | sed -E "s/refs\/(heads|tags)\///w ref.txt"']
68 command: [sh, -c]
69 outputs:
70 parameters:
71 - name: tag
72 valueFrom:
73 path: "ref.txt"
74
75 - name: unit-test
76 inputs:
77 artifacts:
78 - name: source
79 path: "{{workflow.parameters.src-path}}"
80 git:
81 repo: "{{workflow.parameters.github-url}}"
82 revision: "{{workflow.parameters.commit}}"
83 outputs:
84 artifacts:
85 - name: source
86 path: "{{workflow.parameters.src-path}}"
87 container:
88 image: dictybase/node-runner
89 command: ["/bin/sh", "-c"]
90 args: ["cp /opt/clientConfig.js {{workflow.parameters.src-path}}/src/utils/ && \
91 npm ci && \
92 npm test"
93 ]
94 workingDir: "{{workflow.parameters.src-path}}"
95 resources:
96 limits:
97 memory: 768Mi
98 cpu: 2000m
99
100 - name: build
101 inputs:
102 artifacts:
103 - name: source
104 path: "{{workflow.parameters.src-path}}"
105 outputs:
106 artifacts:
107 - name: source
108 path: "{{workflow.parameters.src-path}}"
109 container:
110 image: dictybase/frontend-builder:{{workflow.parameters.frontend-tag}}
111 command: ["/bin/sh", "-c"]
112 args: ["npm run build"]
113 workingDir: "{{workflow.parameters.src-path}}"
114 resources:
115 limits:
116 memory: 768Mi
117 cpu: 2000m
118
119 - name: image-build-push
120 inputs:
121 artifacts:
122 - name: source
123 path: "{{workflow.parameters.src-path}}"
124 parameters:
125 - name: tag
126 container:
127 image: "{{workflow.parameters.builder-image}}:{{workflow.parameters.builder-tag}}"
128 args: ["--dockerfile=./Dockerfile",
129 "--context={{workflow.parameters.src-path}}",
130 "--destination=dictybase/{{workflow.parameters.repo}}:{{inputs.parameters.tag}}",
131 "--cache=true",
132 "--cache-repo=dictybase/{{workflow.parameters.repo}}-cache"
133 ]
134 resources:
135 limits:
136 memory: 768Mi
137 cpu: 2000m
138 volumeMounts:
139 - name: docker-secret
140 mountPath: /.docker
141 volumes:
142 - name: docker-secret
143 secret:
144 secretName: docker-secret