-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.pipeline.yml
64 lines (60 loc) · 1.66 KB
/
.pipeline.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
include:
- project: "devops/gitlab/ci-templates/general"
file:
- ".install_hashicorp_vault.yml"
- ".vault_jwt_auth.yml"
- project: "devops/gitlab/ci-templates/ruby"
ref: "sans-dind"
file:
- ".rspec.yml"
- ".rubocop.yml"
stages:
- test
- deploy
rspec_app_test:
stage: test
image: ruby:3.2.2
before_script:
- bundle install -j $(nproc)
extends:
- .rspec
tags:
- build
rubocop_app_test:
stage: test
image: ruby:3.2.2
before_script:
- bundle install -j $(nproc)
extends:
- .rubocop
tags:
- build
# This step was inspired from Gitlab's example of gem publication:
# https://gitlab.com/gitlab-org/quality/pipeline-common/-/blob/master/ci/gem-release.yml
gem_publication:
stage: deploy
image: ruby:3.2.2
variables:
GEMSPEC_FILE: "${CI_PROJECT_NAME}.gemspec"
before_script:
- !reference [.install_hashicorp_vault, before_script]
- !reference [.vault_jwt_auth, before_script]
- export GEM_HOST_API_KEY="$(vault kv get -field=rubygems_api_key ${VAULT_KV_ENDPOINT}${ENVIRONMENT})"
- |
gem -v
rm -f ./*.gem
[ -f "${GEMSPEC_FILE}" ] || (echo "No ${GEMSPEC_FILE} file found!" && exit 1)
- '[ -n "${GEM_HOST_API_KEY}" ] || (echo "GEM_HOST_API_KEY is not set!" && exit 1)'
script:
- GEM_FILE=$(echo "${CI_PROJECT_NAME}-${CI_COMMIT_TAG:1}.gem")
- |
gem build "${GEMSPEC_FILE}"
[ -f "${GEM_FILE}" ] || (echo "No ${GEM_FILE} file found!" && exit 1)
- '[ "${DISABLE_GEM_PUSH}" == "true" ] || gem push "${GEM_FILE}"'
rules:
- if: $CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+(\.[a-zA-Z0-9]+)?$/
artifacts:
paths:
- "*.gem"
tags:
- deploy