From 70823bb3edd408ecd3f8b9da523f695df58e84d3 Mon Sep 17 00:00:00 2001 From: DeveloperDurp Date: Sun, 5 May 2024 08:37:35 -0500 Subject: [PATCH] update --- pipeline.yml | 10 +++--- pipelines/golang.yml | 33 ++++++++++--------- scripts/checkvariable/version.sh | 9 +++++ .../apply.sh} | 0 .../destroy.sh} | 0 .../{terraform-fmt.sh => terraform/fmt.sh} | 0 .../{terraform-init.sh => terraform/init.sh} | 0 .../{terraform-plan.sh => terraform/plan.sh} | 0 .../validate.sh} | 0 templates/docker.tpl.yml | 5 +++ 10 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 scripts/checkvariable/version.sh rename scripts/{terraform-apply.sh => terraform/apply.sh} (100%) rename scripts/{terraform-destroy.sh => terraform/destroy.sh} (100%) rename scripts/{terraform-fmt.sh => terraform/fmt.sh} (100%) rename scripts/{terraform-init.sh => terraform/init.sh} (100%) rename scripts/{terraform-plan.sh => terraform/plan.sh} (100%) rename scripts/{terraform-validate.sh => terraform/validate.sh} (100%) diff --git a/pipeline.yml b/pipeline.yml index 4e4e317..89fecb0 100644 --- a/pipeline.yml +++ b/pipeline.yml @@ -3,8 +3,8 @@ stages: - deploy variables: - GO_VERSION: "1.20" - GOLANGCI_LINT_VERISON: "v1.55.2" + GO_VERSION: "1.22" + GOLANGCI_LINT_VERISON: "v1.58.0" gitlab_generic_package: stage: deploy @@ -19,10 +19,10 @@ gitlab_generic_package: rules: - if: '$PIPELINE =~ /gitlab/' -build_go_api: +build_go: stage: deploy - needs: - - job: compliance + #needs: + # - job: compliance trigger: include: - project: 'developerdurp/yml' diff --git a/pipelines/golang.yml b/pipelines/golang.yml index 3d72e44..6974846 100644 --- a/pipelines/golang.yml +++ b/pipelines/golang.yml @@ -1,6 +1,7 @@ stages: - build - package + - validate - publish include: @@ -26,8 +27,21 @@ gobuild: extends: .golang-build stage: build +docker-build: + extends: .docker_build + stage: build + needs: + - job: gobuild + artifacts: true + - job: version + optional: true + artifacts: true + rules: + - exists: + - "Dockerfile" + docker: - extends: .docker-build-container + extends: .docker_push_gitlab stage: publish needs: - job: gobuild @@ -36,19 +50,8 @@ docker: artifacts: true rules: - if: $CI_COMMIT_REF_NAME == 'main' - - if: $CI_COMMIT_BRANCH =~ '/^release/' - -publish: - extends: .octo_release - stage: publish - needs: - - job: version - artifacts: true - rules: + exists: + - "Dockerfile" - if: $CI_COMMIT_BRANCH =~ '/^release/' exists: - - $OCTO_PROJECT_NAME - - if: $CI_COMMIT_BRANCH =~ 'main' - exists: - - $OCTO_PROJECT_NAME - - when: never + - "Dockerfile" diff --git a/scripts/checkvariable/version.sh b/scripts/checkvariable/version.sh new file mode 100644 index 0000000..1622792 --- /dev/null +++ b/scripts/checkvariable/version.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +#%%MULTILINE_YAML_START +#check for Version variable + +if [ -z "${VERSION}" ]; then + # If not, assign a default value + VERSION=$CI_COMMIT_SHORT_SHA +fi + diff --git a/scripts/terraform-apply.sh b/scripts/terraform/apply.sh similarity index 100% rename from scripts/terraform-apply.sh rename to scripts/terraform/apply.sh diff --git a/scripts/terraform-destroy.sh b/scripts/terraform/destroy.sh similarity index 100% rename from scripts/terraform-destroy.sh rename to scripts/terraform/destroy.sh diff --git a/scripts/terraform-fmt.sh b/scripts/terraform/fmt.sh similarity index 100% rename from scripts/terraform-fmt.sh rename to scripts/terraform/fmt.sh diff --git a/scripts/terraform-init.sh b/scripts/terraform/init.sh similarity index 100% rename from scripts/terraform-init.sh rename to scripts/terraform/init.sh diff --git a/scripts/terraform-plan.sh b/scripts/terraform/plan.sh similarity index 100% rename from scripts/terraform-plan.sh rename to scripts/terraform/plan.sh diff --git a/scripts/terraform-validate.sh b/scripts/terraform/validate.sh similarity index 100% rename from scripts/terraform-validate.sh rename to scripts/terraform/validate.sh diff --git a/templates/docker.tpl.yml b/templates/docker.tpl.yml index 0531192..ec9e40c 100644 --- a/templates/docker.tpl.yml +++ b/templates/docker.tpl.yml @@ -22,7 +22,12 @@ - name: docker:dind entrypoint: ["dockerd-entrypoint.sh", "--tls=false"] script: + - ./scripts/checkvariable/version.sh - ./scripts/docker/build.sh + artifacts: + expire_in: 1 hour + paths: + - $CI_PROJECT_DIR/packages .docker_push_gitlab: image: registry.internal.durp.info/docker:20.10.17