Skip to content

Instantly share code, notes, and snippets.

@rberrelleza
Last active March 14, 2024 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rberrelleza/0009003e08705b053e43e640a2c3f35d to your computer and use it in GitHub Desktop.
Save rberrelleza/0009003e08705b053e43e640a2c3f35d to your computer and use it in GitHub Desktop.
Check if your deployment is a preview environment or a development environment
deploy:
- name: is preview environment?
command: |
# okteto inserts the preview.okteto.com label only on preview environments
kubectl get namespace $OKTETO_NAMESPACE -o jsonpath='{.metadata.labels}' | grep -q "preview.okteto.com"
exit_code=$?
# we add the PREVIEW_ENVIRONMENT variable to the OKTETO_ENV so it can be used in the rest of the deploy commands
if [ $exit_code -eq 0 ]; then
echo "ENVIRONMENT_TYPE=preview" >> $OKTETO_ENV
else
echo "ENVIRONMENT_TYPE=development" >> $OKTETO_ENV
fi
- name: Consume the value
command:
echo "What am I? You are a ${ENVIRONMENT_TYPE} environment"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment