diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml index ae1cd4f..045a051 100644 --- a/bitbucket-pipelines.yml +++ b/bitbucket-pipelines.yml @@ -139,6 +139,14 @@ pipelines: - step: name: Deploy K8s apps (staging) script: + # Set a default branch for local testing or safety if BITBUCKET_BRANCH is not always present + - export BITBUCKET_BRANCH=${BITBUCKET_BRANCH:-notarealbranch} + + # Template argocd/base/applications.yaml in place for the current pipeline run + - envsubst < k8s/argocd/base/applications.yaml > k8s/argocd/base/applications.yaml.tmp + - mv k8s/argocd/base/applications.yaml.tmp k8s/argocd/base/applications.yaml + + # Now run kubectl apply -k. Kustomize will pick up the modified base file. - pipe: atlassian/kubectl-run:3.1.2 variables: KUBE_CONFIG: $KUBE_CONFIG_STG diff --git a/k8s/applications/templates/argocd.yaml b/k8s/applications/templates/argocd.yaml index 301c62a..dc311c2 100644 --- a/k8s/applications/templates/argocd.yaml +++ b/k8s/applications/templates/argocd.yaml @@ -10,7 +10,7 @@ spec: source: path: k8s/argocd/overlays/{{ .Values.environment }} repoURL: 'git@bitbucket.org:jamkazam/video-iac.git' - targetRevision: {{ .Values.gitBranch }} + targetRevision: ${CI_BUILD_BRANCH} project: default # syncPolicy: # automated: