From 35f80f21c8b0b7a86881224bcc5192214935b347 Mon Sep 17 00:00:00 2001 From: Garet Halliday <me@garet.holiday> Date: Fri, 25 Aug 2023 18:20:05 -0500 Subject: [PATCH] ci --- .gitlab-ci.jsonnet | 37 +++++++++++++++++++++++++++++++++++ .gitlab-ci.yml | 19 ++++++++++++++++++ Dockerfile => cgat.Dockerfile | 0 3 files changed, 56 insertions(+) create mode 100644 .gitlab-ci.jsonnet create mode 100644 .gitlab-ci.yml rename Dockerfile => cgat.Dockerfile (100%) diff --git a/.gitlab-ci.jsonnet b/.gitlab-ci.jsonnet new file mode 100644 index 00000000..cf841b5c --- /dev/null +++ b/.gitlab-ci.jsonnet @@ -0,0 +1,37 @@ +local jobs = [ + {name: "cgat", merge: {}}, +]; +local param_job(image,tag_var, merge = {}) = std.mergePatch({ + stage: 'build', + image: { + name: 'gcr.io/kaniko-project/executor:debug', + entrypoint: [''], + }, + script: [ + 'mkdir -p /kaniko/.docker', + @'echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64)\"}}}" > /kaniko/.docker/config.json', + std.strReplace(||| + /kaniko/executor + --context ${CI_PROJECT_DIR} + --cache=true + --build-arg GOPROXY + --cache-repo="${CI_REGISTRY_IMAGE}/kaniko/cache" + --registry-mirror=mirror.gfx.cafe + --registry-mirror=mirror.gcr.io + --registry-mirror=index.docker.io + --dockerfile "${CI_PROJECT_DIR}/%(img)s.Dockerfile" + --destination "${CI_REGISTRY_IMAGE}/%(img)s:%(tag_var)s" + --destination "${CI_REGISTRY_IMAGE}/%(img)s:latest" + ||| % {img: image, tag_var: tag_var}, "\n", " "), + ] + }, merge); +{ + [job.name+"-tag"]: param_job(job.name,"${CI_COMMIT_TAG}",std.mergePatch(job.merge, {only:["tags"]})) + for job in jobs +} + { + [job.name+"-master"]: param_job(job.name,"master",std.mergePatch(job.merge, {only:{refs:["master"]}})) + for job in jobs +} + { + [job.name]: param_job(job.name,"${CI_COMMIT_SHORT_SHA}",job.merge) + for job in jobs +} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..af68b33c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,19 @@ +jsonnet: + stage: build + image: alpine:latest + script: + - apk add -U jsonnet + - jsonnet .gitlab-ci.jsonnet > generated-config.yml + artifacts: + paths: + - generated-config.yml + +trigger-builds: + stage: build + needs: + - jsonnet + trigger: + include: + - artifact: generated-config.yml + job: jsonnet + strategy: depend diff --git a/Dockerfile b/cgat.Dockerfile similarity index 100% rename from Dockerfile rename to cgat.Dockerfile -- GitLab