1- version : ' 1.0'
2-
1+ version : " 1.0"
2+ stages :
3+ - clone
4+ - prepare
5+ - build
6+ - test
7+ - release
38steps :
49
10+ main_clone :
11+ title : ' Cloning main repository...'
12+ stage : clone
13+ type : git-clone
14+ repo : ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
15+ revision : ${{CF_BRANCH}}
16+ git : ${{GIT_CONTEXT}}
517
6- install_dependencies :
7- title : ' Installing testing dependencies'
8- image : node:11.10.0
18+ prepare_env_vars :
19+ title : ' Preparing environment variables...'
20+ stage : prepare
21+ image : codefreshio/ci-helpers
22+ working_directory : ${{main_clone}}
923 commands :
10- - yarn install --frozen-lockfile
24+ - cf_export NODE_VERSION=11.10.0
25+ - cf_export SERVICE_VERSION=$(yq r service.yaml version)
26+ - cf_export IMAGE_NAME=codefresh/cf-container-logger
1127
12- eslint :
13- title : ' Running linting logic'
14- image : node:11.10.0
28+ validate_version :
29+ title : ' Validating the service version...'
30+ stage : prepare
31+ image : codefreshio/ci-helpers
32+ fail_fast : false
1533 commands :
16- - yarn lint
17- - yarn no-onlys
34+ - |
35+ err() { echo -e "\e[31m$@\e[0m" ; return 1 ; }
36+ ok() { echo -e "\e[32m$@\e[0m" ; return 0 ; }
1837
19- unit_test_step :
20- image : node:11.10.0
21- environment :
22- - COVERALLS_TOKEN=${{COVERALLS_TOKEN}}
23- commands :
24- - yarn test
38+ current_version=${SERVICE_VERSION}
39+ last_version=$(git describe --abbrev=0 --tags)
40+ echo "Current version is $current_version, last version - $last_version"
41+ semver-cli greater $current_version $last_version && ok "Version check ok" || err "Please the update the version in the service.yaml file"
2542
26- build_step :
27- title : " Building production image"
43+ build_image :
44+ title : " Building the image..."
45+ stage : build
2846 type : build
29- image_name : codefresh/cf-container-logger
30- on_success :
31- metadata :
32- set :
33- - ' ${{build_step.imageId}} ' :
34- - CF_QUALITY : true
35-
36- push to registry :
37- type : push
38- candidate : ${{build_step}}
39- tag : ${{CF_BRANCH}}
47+ working_directory : ${{main_clone}}
48+ dockerfile : ./Dockerfile
49+ image_name : ${{IMAGE_NAME}}
50+ tag : ${{CF_BRANCH_TAG_NORMALIZED}}
51+
52+ run_tests :
53+ title : " Running unit tests & linting"
54+ stage : test
55+ image : node:${{NODE_VERSION}}
56+ commands :
57+ - yarn install --frozen-lockfile
58+ - yarn lint
59+ - yarn no-onlys
60+ - yarn test
61+
62+ approve_existing_version_update :
63+ type : pending-approval
64+ stage : release
65+ title : " Are you sure you want to update already existing image version?"
66+ description : |
67+ "Used for reverting changes without raising the service version"
68+ when :
69+ branch :
70+ only : [master]
71+ steps :
72+ - name : validate_version
73+ on :
74+ - failure
75+
76+ release :
77+ type : parallel
78+ stage : release
79+ steps :
80+
81+ push_image_prod :
82+ type : push
83+ title : " Pushing the image to the public registry..."
84+ stage : release
85+ image_name : ' ${{IMAGE_NAME}}'
86+ registry : " ${{REGISTRY_INTEGRATION}}"
87+ candidate : " ${{build_image}}"
88+ tags :
89+ - " ${{SERVICE_VERSION}}"
90+ - " latest"
91+ when :
92+ branch :
93+ only : [master]
0 commit comments