Skip to content

Commit

Permalink
Add push image to Flare infra pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
vidbregar-flare committed Nov 14, 2024
1 parent 372b522 commit d250e26
Showing 1 changed file with 74 additions and 11 deletions.
85 changes: 74 additions & 11 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# templates

.test_template: &test
stage: test
variables:
Expand All @@ -25,27 +25,28 @@
stages:
- build
- test
- release_flare_infra

build_branches:
<<: *build
script:
- /kaniko/executor
--context $CI_PROJECT_DIR
--dockerfile $CI_PROJECT_DIR/Dockerfile
--destination $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH
--cache=true
- /kaniko/executor
--context $CI_PROJECT_DIR
--dockerfile $CI_PROJECT_DIR/Dockerfile
--destination $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH
--cache=true
--cache-ttl=120h
only:
- branches

build_tags:
<<: *build
script:
- /kaniko/executor
--context $CI_PROJECT_DIR
--dockerfile $CI_PROJECT_DIR/docker/remote/Dockerfile
--destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
--cache=true
- /kaniko/executor
--context $CI_PROJECT_DIR
--dockerfile $CI_PROJECT_DIR/Dockerfile
--destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
--cache=true
--cache-ttl=120h
only:
- tags
Expand Down Expand Up @@ -73,3 +74,65 @@ test_django:
coverage_report:
coverage_format: cobertura
path: coverage.xml

.release_flare_infra:
stage: release_flare_infra
rules:
- if: "$CI_COMMIT_TAG"

# todo: Remove once GitHub repo is public and use images from ghcr
release_flare_infra:auth:
extends: .release_flare_infra
image: registry.gitlab.com/flarenetwork/infra/pipeliner:latest
id_tokens:
OIDC_JOB_TOKEN:
aud: https://gitlab.com
variables:
GCP_PROJECT: "flare-network-shared"
GCP_PROJECT_NUMBER: "940168819002"
before_script:
- >
WORKLOAD_IDENTITY_POOL=$([ "$CI_COMMIT_REF_PROTECTED" == "true" ] &&
echo "cr-oidc-gitlab-protected-pool" ||
echo "cr-oidc-gitlab-pool")
- >
WORKLOAD_IDENTITY_POOL_PROVIDER=$([ "$CI_COMMIT_REF_PROTECTED" == "true" ] &&
echo "oidc-gitlab-protected" ||
echo "oidc-gitlab-pool-provider")
- >
SERVICE_ACCOUNT_EMAIL=$([ "$CI_COMMIT_REF_PROTECTED" == "true" ] &&
echo "cr-prtctd-oidc-cntnr-img-bldr@flare-network-shared.iam.gserviceaccount.com" ||
echo "cr-oidc-cntnr-img-bldr@flare-network-shared.iam.gserviceaccount.com")
- . pipeliner gcloud-setup
script:
- echo "GOOGLE_OAUTH_ACCESS_TOKEN=$GOOGLE_OAUTH_ACCESS_TOKEN" > auth.env
artifacts:
reports:
dotenv:
- auth.env

release_flare_infra:
extends: .release_flare_infra
image:
name: gcr.io/kaniko-project/executor:v1.18.0-debug
entrypoint: [""]
needs:
- job: release_flare_infra:auth
artifacts: true
before_script:
- mkdir -p /kaniko/.docker
- auth_encoded=$(echo -n "oauth2accesstoken:$GOOGLE_OAUTH_ACCESS_TOKEN" | base64 | tr -d "\n")
- echo "{\"auths\":{\"europe-west1-docker.pkg.dev\":{\"auth\":\"$auth_encoded\",\"email\":\"[email protected]\"}}}" > /kaniko/.docker/config.json
script:
- >
args="--context ${CI_PROJECT_DIR}/.
--dockerfile ${CI_PROJECT_DIR}/Dockerfile
--cache=true
--destination europe-west1-docker.pkg.dev/flare-network-staging/containers/data-availability:latest
--destination europe-west1-docker.pkg.dev/flare-network-staging/containers/data-availability:${CI_COMMIT_TAG}"
- >-
if [[ $CI_COMMIT_REF_PROTECTED == "true" ]]; then
args="$args --destination europe-west1-docker.pkg.dev/flare-network-production/containers/data-availability:latest"
args="$args --destination europe-west1-docker.pkg.dev/flare-network-production/containers/data-availability:${CI_COMMIT_TAG}"
fi
- /kaniko/executor $args

0 comments on commit d250e26

Please sign in to comment.