-
Notifications
You must be signed in to change notification settings - Fork 4
/
workflow-git-vault-push.yaml
71 lines (71 loc) · 2.15 KB
/
workflow-git-vault-push.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
name: git-vault-push
namespace: argo
spec:
entrypoint: workflow-steps
serviceAccountName: argo
arguments:
parameters:
- name: git-repo-path
value: '/src'
- name: git-repo-url
value: 'github.com/jayfray12/argo-workflow-vault-integration.git'
- name: git-secret-name
value: 'git-creds'
- name: git-repo-revision
value: 'main'
volumeClaimTemplates:
- metadata:
name: workdir
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Mi
templates:
- name: git-clone
metadata:
annotations:
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/role: "git-creds"
vault.hashicorp.com/secret-volume-path: "/home"
vault.hashicorp.com/agent-inject-secret-token: "secret/git-creds"
vault.hashicorp.com/agent-inject-template-token: |
{{- with secret "secret/git-creds" -}}
{{ .Data.data.token }}
{{- end }}
container:
image: alpine/git
command: [sh, -c]
args: ["git clone -q -b {{workflow.parameters.git-repo-revision}} https://`cat /home/token`@{{workflow.parameters.git-repo-url}} . && cat /home/token"]
workingDir: "/gen-source{{workflow.parameters.git-repo-path}}"
volumeMounts:
- name: workdir
mountPath: /gen-source
- name: git-push
inputs:
parameters:
- name: git-token
container:
image: alpine/git
command: [sh, -c]
args: ["bin/git-push.sh 'https://{{inputs.parameters.git-token}}@{{workflow.parameters.git-repo-url}}'"]
workingDir: "/gen-source{{workflow.parameters.git-repo-path}}"
volumeMounts:
- name: workdir
mountPath: /gen-source
- name: workflow-steps
dag:
tasks:
- name: git-clone-step
template: git-clone
- name: git-push-step
template: git-push
dependencies: [git-clone-step]
arguments:
parameters:
- name: git-token
value: "{{tasks.git-clone-step.outputs.result}}"