stages: - build - test - deploy # dummy stage to follow the template guidelines - review - dast - staging - canary - production - incremental rollout 10% - incremental rollout 25% - incremental rollout 50% - incremental rollout 100% - performance - cleanup build: tags: - shell stage: build script: - | if [[ -z "$CI_COMMIT_TAG" ]]; then export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG} export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_SHA} else export CI_APPLICATION_REPOSITORY=${CI_APPLICATION_REPOSITORY:-$CI_REGISTRY_IMAGE} export CI_APPLICATION_TAG=${CI_APPLICATION_TAG:-$CI_COMMIT_TAG} fi if [[ -n "$CI_REGISTRY" && -n "$CI_REGISTRY_USER" ]]; then echo "Logging to GitLab Container Registry with CI credentials..." echo "$CI_REGISTRY_PASSWORD" | docker login -u "$CI_REGISTRY_USER" --password-stdin "$CI_REGISTRY" fi image_previous="$CI_APPLICATION_REPOSITORY:$CI_COMMIT_BEFORE_SHA" image_tagged="$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG" image_latest="$CI_APPLICATION_REPOSITORY:latest" docker image pull "$image_tagged" || docker image pull "$image_latest" || true docker build $build_secret_args --tag "$CI_APPLICATION_REPOSITORY:$CI_APPLICATION_TAG" --tag "$image_latest" . docker push "$image_tagged" docker push "$image_latest" release staging: tags: - shell stage: deploy rules: - if: "$CI_COMMIT_TAG != null" when: manual - if: "$CI_COMMIT_TAG == null" when: never script: - kubectl apply -f kubernetes/stg-deployment-api.yaml release production: tags: - shell stage: production rules: - if: "$CI_COMMIT_TAG != null" when: manual - if: "$CI_COMMIT_TAG == null" when: never script: - kubectl apply -f kubernetes/prd-deployment-api.yaml