-
Notifications
You must be signed in to change notification settings - Fork 19
/
manifests.yaml
71 lines (65 loc) · 2.49 KB
/
manifests.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: WorkflowTemplate
metadata:
name: argocd-sync-and-wait
annotations:
workflows.argoproj.io/description: >-
This task syncs (deploys) an Argo CD application and waits for it to be healthy.
To do so, it requires the address of the Argo CD server and some form of
authentication either a username/password or an authentication token.
workflows.argoproj.io/maintainer: '@dcherman'
workflows.argoproj.io/tags: argocd
workflows.argoproj.io/version: '>= 2.9.0'
spec:
entrypoint: argocd-sync-and-wait
templates:
- name: argocd-sync-and-wait
inputs:
parameters:
- name: argocd-version
value: v1.6.0
- name: application-name
- name: revision
value: HEAD
- name: flags
value: --
- name: argocd-server-address
- name: argocd-credentials-secret
script:
image: argoproj/argocd:{{inputs.parameters.argocd-version}}
command: [bash]
env:
- name: ARGOCD_AUTH_TOKEN
valueFrom:
secretKeyRef:
name: "{{inputs.parameters.argocd-credentials-secret}}"
key: token
optional: true
- name: ARGOCD_USERNAME
valueFrom:
secretKeyRef:
name: "{{inputs.parameters.argocd-credentials-secret}}"
key: username
optional: true
- name: ARGOCD_PASSWORD
valueFrom:
secretKeyRef:
name: "{{inputs.parameters.argocd-credentials-secret}}"
key: password
optional: true
- name: ARGOCD_SERVER
value: "{{inputs.parameters.argocd-server-address}}"
source: |
#!/bin/bash
set -euo pipefail
if [[ -z $ARGOCD_AUTH_TOKEN ]] && [[ -z "$ARGOCD_USERNAME" || -z "$ARGOCD_PASSWORD" ]]; then
echo "Either the ARGOCD_AUTH_TOKEN must be specified, or the ARGOCD_USERNAME/ARGOCD_PASSWORD must be specified."
exit 1
fi
if [ -z $ARGOCD_AUTH_TOKEN ]; then
yes | argocd login "$ARGOCD_SERVER" --username=$ARGOCD_USERNAME --password=$ARGOCD_PASSWORD {{inputs.parameters.flags}}
fi
echo "Running as ArgoCD User:"
argocd account get-user-info {{inputs.parameters.flags}}
argocd app sync {{inputs.parameters.application-name}} --revision {{inputs.parameters.revision}} {{inputs.parameters.flags}}
argocd app wait {{inputs.parameters.application-name}} --health {{inputs.parameters.flags}}