ci: refactor to use global ci templates
This commit is contained in:
parent
b406d732c3
commit
3b41630e91
1 changed files with 6 additions and 79 deletions
|
|
@ -1,80 +1,7 @@
|
|||
default:
|
||||
image:
|
||||
name: hashicorp/terraform:1.0.0
|
||||
entrypoint: [""]
|
||||
include:
|
||||
- project: mareshq/ci
|
||||
file: terraform/modules.gitlab-ci.yml
|
||||
ref: main
|
||||
|
||||
stages:
|
||||
- init
|
||||
- validation
|
||||
- pre-release
|
||||
- release
|
||||
|
||||
init:
|
||||
stage: init
|
||||
script:
|
||||
- terraform init -input=false
|
||||
artifacts:
|
||||
untracked: false
|
||||
expire_in: 30 days
|
||||
paths:
|
||||
- .terraform
|
||||
- .terraform.lock.hcl
|
||||
|
||||
format:
|
||||
stage: validation
|
||||
script:
|
||||
- terraform fmt -recursive -check -diff .
|
||||
|
||||
validate:
|
||||
stage: validation
|
||||
script:
|
||||
- terraform validate
|
||||
|
||||
tag release:
|
||||
stage: pre-release
|
||||
image: node:16-buster-slim
|
||||
before_script:
|
||||
- apt-get update && apt-get upgrade -y --no-install-recommends git-core ca-certificates
|
||||
- npm install -g semantic-release @semantic-release/gitlab
|
||||
script:
|
||||
- semantic-release -b ${CI_COMMIT_REF_NAME}
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: never
|
||||
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
|
||||
when: always
|
||||
- if: $CI_COMMIT_MSG =~ /^chore\(CHANGELOG\):/
|
||||
when: never
|
||||
|
||||
tag release dry-run:
|
||||
stage: pre-release
|
||||
image: node:16-buster-slim
|
||||
before_script:
|
||||
- apt-get update && apt-get upgrade -y --no-install-recommends git-core ca-certificates
|
||||
- npm install -g semantic-release @semantic-release/gitlab
|
||||
script:
|
||||
- semantic-release -d -b ${CI_COMMIT_REF_NAME}
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: never
|
||||
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
|
||||
when: never
|
||||
- if: $CI_COMMIT_MSG =~ /^chore\(CHANGELOG\):/
|
||||
when: never
|
||||
|
||||
publish:
|
||||
stage: release
|
||||
image: curlimages/curl:latest
|
||||
variables:
|
||||
TERRAFORM_MODULE_NAME: ${CI_PROJECT_NAME}
|
||||
TERRAFORM_MODULE_VERSION: ${CI_COMMIT_TAG}
|
||||
TERRAFORM_MODULE_SYSTEM: gitlab
|
||||
ARCHIVE_FILE: ${TERRAFORM_MODULE_NAME}-${TERRAFORM_MODULE_SYSTEM}-${TERRAFORM_MODULE_VERSION}.tar.gz
|
||||
UPLOAD_ENDPOINT: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/terraform/modules/${TERRAFORM_MODULE_NAME}/${TERRAFORM_MODULE_SYSTEM}/${TERRAFORM_MODULE_VERSION}/file
|
||||
script:
|
||||
- |
|
||||
set -e
|
||||
tar -cvzf "${ARCHIVE_FILE}" --exclude=./.terraform --exclude=./.terraform.lock.hcl --exclude=./.git --exclude=./.git-hooks --exclude=./Makefile --exclude=./.editorconfig --exclude=./.gitignore --exclude=./.releaserc.yml --exclude=./.gitlab-ci.yml .
|
||||
curl --fail-with-body --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file "${ARCHIVE_FILE}" "${UPLOAD_ENDPOINT}"
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
variables:
|
||||
TERRAFORM_MODULE_SYSTEM: gitlab
|
||||
|
|
|
|||
Reference in a new issue