040-sensor-github.yaml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. apiVersion: argoproj.io/v1alpha1
  2. kind: WorkflowTemplate
  3. metadata:
  4. name: ci-workflow
  5. spec:
  6. inputs:
  7. parameters:
  8. - name: revision
  9. steps:
  10. - - name: build
  11. template: build-golang-example
  12. arguments:
  13. parameters:
  14. - name: revision
  15. value: "{{inputs.parameters.revision}}"
  16. # the test step expands into three parallel steps running
  17. # different operating system images. each mounts the workdir
  18. # and runs the compiled binary from the build step.
  19. - - name: test
  20. template: run-hello
  21. arguments:
  22. parameters:
  23. - name: os-image
  24. value: "{{item.image}}:{{item.tag}}"
  25. withItems:
  26. - { image: "debian", tag: "9.1" }
  27. - { image: "alpine", tag: "3.6" }
  28. - { image: "ubuntu", tag: "17.10" }
  29. ---
  30. apiVersion: argoproj.io/v1alpha1
  31. kind: WorkflowTemplate
  32. metadata:
  33. name: build-golang-example
  34. spec:
  35. inputs:
  36. parameters:
  37. - name: revision
  38. artifacts:
  39. - name: code
  40. path: /go/src/github.com/golang/example
  41. git:
  42. repo: https://github.com/golang/example.git
  43. revision: "{{inputs.parameters.revision}}"
  44. container:
  45. image: golang:1.8
  46. command: [sh, -c]
  47. args: [
  48. "
  49. cd /go/src/github.com/golang/example/hello &&
  50. git status &&
  51. go build -v .
  52. ",
  53. ]
  54. volumeMounts:
  55. - name: workdir
  56. mountPath: /go
  57. ---
  58. apiVersion: argoproj.io/v1alpha1
  59. kind: WorkflowTemplate
  60. metadata:
  61. name: run-hello
  62. spec:
  63. inputs:
  64. parameters:
  65. - name: os-image
  66. container:
  67. image: "{{inputs.parameters.os-image}}"
  68. command: [sh, -c]
  69. args: [
  70. "
  71. uname -a ;
  72. cat /etc/os-release ;
  73. /go/src/github.com/golang/example/hello/hello
  74. ",
  75. ]
  76. volumeMounts:
  77. - name: workdir
  78. mountPath: /go
  79. ---
  80. apiVersion: argoproj.io/v1alpha1
  81. kind: Sensor
  82. metadata:
  83. name: github
  84. spec:
  85. template:
  86. serviceAccountName: argo-events-sa
  87. dependencies:
  88. - name: test-dep
  89. gatewayName: github
  90. eventName: example
  91. subscription:
  92. http:
  93. port: 9300
  94. triggers:
  95. - template:
  96. name: github-workflow-trigger
  97. k8s:
  98. group: argoproj.io
  99. version: v1alpha1
  100. resource: workflows
  101. operation: create
  102. source:
  103. resource:
  104. apiVersion: argoproj.io/v1alpha1
  105. kind: Workflow
  106. metadata:
  107. generateName: github-
  108. # generateName: ci-workflow-
  109. spec:
  110. serviceAccountName: workflow
  111. entrypoint: whalesay
  112. # entrypoint: ci-workflow
  113. # workflowTemplateRef:
  114. # name: ci-workflow
  115. arguments:
  116. parameters:
  117. - name: message
  118. # value will get overridden by the event payload
  119. value: hello world
  120. templates:
  121. - name: whalesay
  122. inputs:
  123. parameters:
  124. - name: message
  125. container:
  126. image: docker/whalesay:latest
  127. command: [cowsay]
  128. args: ["{{inputs.parameters.message}}"]
  129. parameters:
  130. - src:
  131. dependencyName: test-dep
  132. dest: spec.arguments.parameters.0.value
  133. # - template:
  134. # name: github-workflow-trigger
  135. # k8s:
  136. # group: argoproj.io
  137. # version: v1alpha1
  138. # resource: workflows
  139. # operation: create
  140. # source:
  141. # resource:
  142. # apiVersion: argoproj.io/v1alpha1
  143. # kind: Workflow
  144. # metadata:
  145. # generateName: github-
  146. # spec:
  147. # serviceAccountName: workflow
  148. # entrypoint: whalesay
  149. # arguments:
  150. # parameters:
  151. # - name: message
  152. # # value will get overridden by the event payload
  153. # value: hello world
  154. # templates:
  155. # - name: whalesay
  156. # inputs:
  157. # parameters:
  158. # - name: message
  159. # container:
  160. # image: docker/whalesay:latest
  161. # command: [cowsay]
  162. # args: ["{{inputs.parameters.message}}"]
  163. # parameters:
  164. # - src:
  165. # dependencyName: test-dep
  166. # dest: spec.arguments.parameters.0.value
  167. # --- daqui pra baixo
  168. # apiVersion: argoproj.io/v1alpha1
  169. # kind: Sensor
  170. # metadata:
  171. # name: github
  172. # namespace: argo-events
  173. # spec:
  174. # template:
  175. # serviceAccountName: argo-events-sa
  176. # dependencies:
  177. # - name: test-dep
  178. # gatewayName: github
  179. # eventName: example
  180. # subscription:
  181. # http:
  182. # port: 9300
  183. # triggers:
  184. # - template:
  185. # name: github-workflow-trigger
  186. # k8s:
  187. # group: argoproj.io
  188. # version: v1alpha1
  189. # resource: workflows
  190. # operation: create
  191. # source:
  192. # resource:
  193. # apiVersion: argoproj.io/v1alpha1
  194. # kind: Workflow
  195. # metadata:
  196. # generateName: github-
  197. # spec:
  198. # # serviceAccountName: workflow
  199. # entrypoint: whalesay
  200. # arguments:
  201. # parameters:
  202. # - name: message
  203. # # value will get overridden by the event payload
  204. # value: hello world
  205. # templates:
  206. # - name: whalesay
  207. # inputs:
  208. # parameters:
  209. # - name: message
  210. # container:
  211. # image: docker/whalesay:latest
  212. # command: [cowsay]
  213. # args: ["{{inputs.parameters.message}}"]
  214. # parameters:
  215. # - src:
  216. # dependencyName: test-dep
  217. # dest: spec.arguments.parameters.0.value
  218. # # triggers:
  219. # # - template:
  220. # # name: github-workflow-trigger
  221. # # k8s:
  222. # # group: argoproj.io
  223. # # version: v1alpha1
  224. # # resource: workflows
  225. # # operation: create
  226. # # source:
  227. # # resource:
  228. # # apiVersion: argoproj.io/v1alpha1
  229. # # kind: Workflow
  230. # # metadata:
  231. # # generateName: ci-workflow-
  232. # # spec:
  233. # # # ttlStrategy:
  234. # # # secondsAfterCompletion: 10 # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
  235. # # # secondsAfterSuccess: 5 # Time to live after workflow is successful
  236. # # # secondsAfterFailure: 5 # Time to live after workflow fails
  237. # # serviceAccountName: workflow
  238. # # # entrypoint: ci-workflow
  239. # # # entrypoint is the name of the template used as the starting point of the workflow
  240. # # entrypoint: ci-workflow
  241. # # workflowTemplateRef:
  242. # # name: ci-workflow
  243. # # # the 'ci-workflow' template accepts an parameter 'revision', with a default of 'master'.
  244. # # # this can be overridden via argo CLI (e.g. `argo submit ci.yaml -p revision=0dea2d0`)
  245. # # arguments:
  246. # # parameters:
  247. # # - name: revision
  248. # # value: master
  249. # # # a temporary volume, named workdir, will be used as a working directory
  250. # # # for this workflow. This volume is passed around from step to step.
  251. # # volumeClaimTemplates:
  252. # # - metadata:
  253. # # name: workdir
  254. # # spec:
  255. # # accessModes: ["ReadWriteOnce"]
  256. # # resources:
  257. # # requests:
  258. # # storage: 1Gi
  259. # # parameters:
  260. # # - src:
  261. # # dependencyName: test-dep
  262. # # dest: spec.arguments.parameters.0.value