Last active
March 31, 2022 16:16
-
-
Save ofen/c1a176e81fe778fd0bdae3f3afde3599 to your computer and use it in GitHub Desktop.
.gitlab-ci.yml for golang projects w/ private modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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