Skip to content

Instantly share code, notes, and snippets.

@ofen
Last active March 31, 2022 16:16
Show Gist options
  • Save ofen/c1a176e81fe778fd0bdae3f3afde3599 to your computer and use it in GitHub Desktop.
Save ofen/c1a176e81fe778fd0bdae3f3afde3599 to your computer and use it in GitHub Desktop.
.gitlab-ci.yml for golang projects w/ private modules
---
build:
variables:
GOPRIVATE: git.example.com/*
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
stage: build
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- mkdir -p ${HOME}
- echo -e "machine ${CI_SERVER_HOST}\nlogin gitlab-ci-token\npassword ${CI_BUILD_TOKEN}" > ${HOME}/.netrc
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}"
--destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}"
--destination "${CI_REGISTRY_IMAGE}:latest"
rules:
- if: $CI_COMMIT_TAG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment