Skip to content

Commit 9bd08eb

Browse files
adds the ability to turn on github-deployment-hook within the chart (#98)
* adds the ability to turn on github-deployment-hook within the chart * revert unrelated change
1 parent b99d036 commit 9bd08eb

File tree

6 files changed

+149
-1
lines changed

6 files changed

+149
-1
lines changed

charts/application-core/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 4.5.2
18+
version: 4.6.0
1919

2020

2121
maintainers:

charts/application-core/templates/_helpers.tpl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,36 @@ Create the name of the service account to use
100100
{{- default "default" .Values.serviceAccount.name }}
101101
{{- end }}
102102
{{- end }}
103+
104+
{{/*
105+
Build the Env vars that get sent to github-deployment-hook
106+
*/}}
107+
{{- define "application-core.github-deployment-hook.env" }}
108+
- name: ENVIRONMENT_URL
109+
valueFrom:
110+
configMapKeyRef:
111+
name: {{ .Values.githubDeploymentHook.configMapName }}
112+
key: {{ .Values.githubDeploymentHook.envUrlKey }}
113+
- name: LOG_URL
114+
valueFrom:
115+
configMapKeyRef:
116+
name: {{ .Values.githubDeploymentHook.configMapName }}
117+
key: {{ .Values.githubDeploymentHook.logUrlKey }}
118+
- name: ENVIRONMENT_NAME
119+
valueFrom:
120+
configMapKeyRef:
121+
name: {{ .Values.githubDeploymentHook.configMapName }}
122+
key: {{ .Values.githubDeploymentHook.environmentNameKey }}
123+
- name: GITHUB_REF
124+
valueFrom:
125+
configMapKeyRef:
126+
name: {{ .Values.githubDeploymentHook.configMapName }}
127+
key: {{ .Values.githubDeploymentHook.githubRefKey }}
128+
- name: GITHUB_REPO
129+
value: {{ .Values.githubDeploymentHook.githubRepo }}
130+
- name: GITHUB_TOKEN
131+
valueFrom:
132+
secretKeyRef:
133+
name: {{ .Values.githubDeploymentHook.secretName }}
134+
key: {{ .Values.githubDeploymentHook.githubTokenSecretKey }}
135+
{{- end }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{ if .Values.githubDeploymentHook.enabled }}
2+
---
3+
apiVersion: batch/v1
4+
kind: Job
5+
metadata:
6+
name: {{ .Release.Name }}-post-sync-hook
7+
annotations:
8+
opengov.com/argocd-hook: 'true'
9+
argocd.argoproj.io/hook: PostSync
10+
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
11+
spec:
12+
template:
13+
spec:
14+
containers:
15+
- name: github-deployment-hook
16+
securityContext:
17+
capabilities:
18+
drop:
19+
- ALL
20+
readOnlyRootFilesystem: true
21+
image: {{ .Values.githubDeploymentHook.image }}
22+
env:
23+
{{ include "application-core.github-deployment-hook.env" . | indent 12 }}
24+
- name: DEPLOYMENT_STATE
25+
value: 'success'
26+
resources:
27+
requests:
28+
memory: '64Mi'
29+
cpu: '50m'
30+
limits:
31+
memory: '64Mi'
32+
restartPolicy: Never
33+
{{- end }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{ if .Values.githubDeploymentHook.enabled }}
2+
---
3+
apiVersion: batch/v1
4+
kind: Job
5+
metadata:
6+
name: {{ .Release.Name }}-sync-fail-hook
7+
annotations:
8+
opengov.com/argocd-hook: 'true'
9+
argocd.argoproj.io/hook: SyncFail
10+
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
11+
spec:
12+
template:
13+
spec:
14+
containers:
15+
- name: github-deployment-hook
16+
securityContext:
17+
capabilities:
18+
drop:
19+
- ALL
20+
readOnlyRootFilesystem: true
21+
image: {{ .Values.githubDeploymentHook.image }}
22+
env:
23+
{{ include "application-core.github-deployment-hook.env" . | indent 12 }}
24+
- name: DEPLOYMENT_STATE
25+
value: 'failure'
26+
resources:
27+
requests:
28+
memory: '64Mi'
29+
cpu: '50m'
30+
limits:
31+
memory: '64Mi'
32+
restartPolicy: Never
33+
{{- end }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{ if .Values.githubDeploymentHook.enabled }}
2+
---
3+
apiVersion: batch/v1
4+
kind: Job
5+
metadata:
6+
name: {{ .Release.Name }}-sync-hook
7+
annotations:
8+
opengov.com/argocd-hook: 'true'
9+
argocd.argoproj.io/hook: Sync
10+
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
11+
spec:
12+
template:
13+
spec:
14+
containers:
15+
- name: github-deployment-hook
16+
securityContext:
17+
capabilities:
18+
drop:
19+
- ALL
20+
readOnlyRootFilesystem: true
21+
image: {{ .Values.githubDeploymentHook.image }}
22+
env:
23+
{{ include "application-core.github-deployment-hook.env" . | indent 12 }}
24+
- name: DEPLOYMENT_STATE
25+
value: 'in_progress'
26+
resources:
27+
requests:
28+
memory: '64Mi'
29+
cpu: '50m'
30+
limits:
31+
memory: '64Mi'
32+
restartPolicy: Never
33+
{{- end }}

charts/application-core/values.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ rollouts:
1919
failureLimit: 2
2020
consecutiveSuccessLimit: 2
2121

22+
# Adds a Job that will run to update the Github Deployment Status
23+
githubDeploymentHook:
24+
image: 918073871806.dkr.ecr.us-west-2.amazonaws.com/pro-github-deployment-hook:v0.1.1
25+
enabled: false
26+
githubRepo: 'opengov/repo'
27+
# ConfigMapName that stores the environment name, log url, and github ref
28+
# The keys in the configMap are used to set the environment variables
29+
configMapName: github-deployment-hook
30+
logUrlKey: log_url
31+
environmentNameKey: environment
32+
githubRefKey: ref
33+
envUrlKey: env_url
34+
# Secret that stores the Github Token
35+
secretName: github-deployment-hook
36+
githubTokenSecretKey: GITHUB_TOKEN
37+
2238
# Strategy to use for the rollout. This is only used when rollouts is enabled.
2339
# Overrides the default strategy for the rollout.
2440
rolloutsDeploymentStrategy: {}

0 commit comments

Comments
 (0)