Skip to content

Commit

Permalink
fail pipeline when vault is not created properly
Browse files Browse the repository at this point in the history
  • Loading branch information
bolyachevets committed Nov 12, 2024
1 parent 3ef95fd commit 3102901
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/actions/backend-deploy-job/files/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ steps:
for env_name in "${targets[@]}"; do
export APP_ENV=${env_name}
op inject -f -i ./devops/vaults.gcp.env -o ./devops/vaults.${env_name}
if [[ -z "$(op inject -f -i ./devops/vaults.gcp.env -o ./devops/vaults.${env_name})" ]]; then
echo "Error: failed to generate secrets via 1password vault." >&2
exit 1
fi
export VPC_CONNECTOR=$(awk -F '=' '/^VPC_CONNECTOR/ {print $2}' ./devops/vaults.${env_name})
export VAL=$(awk '{f1=f2=$0; sub(/=.*/,"",f1); sub(/[^=]+=/,"",f2); printf "- name: %s\n value: %s\n",f1,f2}' ./devops/vaults.${env_name} | sed 's/\"/\"/g')
Expand Down
7 changes: 6 additions & 1 deletion .github/actions/backend-deploy/files/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ steps:
local env_name=$1
export APP_ENV=${env_name}
# Inject environment-specific variables
op inject -f -i ./devops/vaults.gcp.env -o "./devops/vaults.${env_name}"
if [[ -z "$(op inject -f -i ./devops/vaults.gcp.env -o ./devops/vaults.${env_name})" ]]; then
echo "Error: failed to generate secrets via 1password vault." >&2
exit 1
fi
# Extract VPC connector and environment variables
export VPC_CONNECTOR=$(awk -F '=' '/^VPC_CONNECTOR/ {print $2}' "./devops/vaults.${env_name}")
Expand Down

0 comments on commit 3102901

Please sign in to comment.