030-sensor-github.yaml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. namespace: argo-events
  85. spec:
  86. template:
  87. serviceAccountName: argo-events-sa
  88. dependencies:
  89. - name: test-dep
  90. gatewayName: github
  91. eventName: example
  92. subscription:
  93. http:
  94. port: 9300
  95. triggers:
  96. - template:
  97. name: github-workflow-trigger
  98. k8s:
  99. group: argoproj.io
  100. version: v1alpha1
  101. resource: workflows
  102. operation: create
  103. source:
  104. resource:
  105. apiVersion: argoproj.io/v1alpha1
  106. kind: Workflow
  107. metadata:
  108. generateName: ci-workflow-
  109. spec:
  110. # ttlStrategy:
  111. # secondsAfterCompletion: 10 # Time to live after workflow is completed, replaces ttlSecondsAfterFinished
  112. # secondsAfterSuccess: 5 # Time to live after workflow is successful
  113. # secondsAfterFailure: 5 # Time to live after workflow fails
  114. serviceAccountName: workflow
  115. # entrypoint: ci-workflow
  116. # entrypoint is the name of the template used as the starting point of the workflow
  117. entrypoint: ci-workflow
  118. workflowTemplateRef:
  119. name: ci-workflow
  120. # the 'ci-workflow' template accepts an parameter 'revision', with a default of 'master'.
  121. # this can be overridden via argo CLI (e.g. `argo submit ci.yaml -p revision=0dea2d0`)
  122. arguments:
  123. parameters:
  124. - name: revision
  125. value: master
  126. # a temporary volume, named workdir, will be used as a working directory
  127. # for this workflow. This volume is passed around from step to step.
  128. volumeClaimTemplates:
  129. - metadata:
  130. name: workdir
  131. spec:
  132. accessModes: ["ReadWriteOnce"]
  133. resources:
  134. requests:
  135. storage: 1Gi
  136. parameters:
  137. - src:
  138. dependencyName: test-dep
  139. dest: spec.arguments.parameters.0.value