Skip to content

Commit

Permalink
Limit deploy to prod or *-staging (#3884)
Browse files Browse the repository at this point in the history
* Limit deploy to prod or *-staging

* update branch name

* fix gitlab syntax
  • Loading branch information
dineshg13 committed Jun 28, 2023
1 parent 03891e0 commit b95565c
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ variables:
BUILD_DD_REGISTRY: registry.ddbuild.io/ci/opentelemetry-collector-contrib
BUILD_DEMO_REGISTRY: 172597598159.dkr.ecr.us-east-1.amazonaws.com/otel-collector-contrib
DOCKERFILE: ci/Dockerfile

stages:
- manaul-jobs
- build
- prod-deploy

# =======================================================================
# Build and deploy the images used for CI
# =======================================================================

.build-ci-image: &build-ci-image
stage: build
tags: ["runner:docker"]
Expand All @@ -25,46 +22,40 @@ stages:
- TAG="$IMAGE_TAG_PREFIX-v$CI_COMMIT_SHORT_SHA"
- docker build --file $DOCKERFILE --tag $BUILD_REGISTRY:$TAG --label target=staging .
- docker push $BUILD_REGISTRY:$TAG

build-image-main:
<<: *build-ci-image
!!merge <<: *build-ci-image
variables:
BUILD_REGISTRY: $BUILD_DD_REGISTRY

build-image-demo:
<<: *build-ci-image
!!merge <<: *build-ci-image
variables:
BUILD_REGISTRY: $BUILD_DEMO_REGISTRY

build-ci-image:
stage: manaul-jobs
when: manual
tags: ["runner:docker"]
image: $CI_IMAGE
script:
- TAG=ci-image-2
- docker build --file ci/Dockerfile.gitlab --tag $BUILD_DD_REGISTRY:$TAG .
- docker build --file ci/Dockerfile.gitlab --tag $BUILD_DD_REGISTRY:$TAG .
- docker push $BUILD_DD_REGISTRY:$TAG

prod-deploy-demo-eks:
stage: prod-deploy
tags: ["runner:docker", "size:large"]
image: $CI_IMAGE
dependencies:
- build-image-demo
only:
refs:
- prod
- "*-staging"
script:
# # For debugging
#- aws sts get-caller-identity
- >-
TEMP_AWS_ACCESS_KEY_ID=$(aws ssm get-parameter --region us-east-1
--name ci.opentelemetry-collector-contrib.eks_access_key
--with-decryption --query Parameter.Value
--out text)
TEMP_AWS_ACCESS_KEY_ID=$(aws ssm get-parameter --region us-east-1 --name ci.opentelemetry-collector-contrib.eks_access_key --with-decryption --query Parameter.Value --out text)
- >-
TEMP_AWS_SECRET_ACCESS_KEY=$(aws ssm get-parameter --region us-east-1
--name ci.opentelemetry-collector-contrib.eks_secret_access_key
--with-decryption --query Parameter.Value
--out text)
TEMP_AWS_SECRET_ACCESS_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.opentelemetry-collector-contrib.eks_secret_access_key --with-decryption --query Parameter.Value --out text)
- export AWS_ACCESS_KEY_ID=$TEMP_AWS_ACCESS_KEY_ID
- export AWS_SECRET_ACCESS_KEY=$TEMP_AWS_SECRET_ACCESS_KEY
# # For debugging
Expand Down

0 comments on commit b95565c

Please sign in to comment.