Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CI example #45

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions example/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,19 @@ ksnotify:
- chmod a+x /usr/bin/ksnotify
script:
- cd "${SKAFFOLD_DIR}"
- skaffold render -p ${ENV} | kubectl diff -f - 2> /dev/null | ksnotify --notifier gitlab --ci gitlab --suppress-skaffold || exit_code=$?
# `exit_code=$?` is for preventing job failure due to kubectl's retrurning exit 1 when there's the diff
# Set digest-source to 'none' to use tags directly from the Kubernetes manifests, that is, use the build result of kustomize
# ref. https://skaffold.dev/docs/references/cli/#skaffold-render
- skaffold render -p ${ENV} --digest-source='none' --output=skaffold_render.yaml
- cat skaffold_render.yaml | kubectl diff -f - > kube.diff && exit_code=0 || exit_code=$?
# the exit status of kubectl diff: 0: no diff, 1: diff exists, 1>: failed with an error
# ref. https://kubernetes.io/docs/reference/kubectl/generated/kubectl_diff/#synopsis
- if [ $exit_code -gt 1 ]; then # so exit status 1 is ok because there just are some difference
- echo "Error while detecting diff. Examine the output of skaffold render"
- exit $exit_code
- fi
- cat kube.diff | ksnotify --notifier gitlab --ci gitlab --suppress-skaffold
artifacts:
path:
- ${SKAFFOLD_DIR}/skaffold_render.yaml
- ${SKAFFOLD_DIR}/kube.diff
when: always
Loading