1- version : ' 1.0'
2-
1+ version : " 1.0"
2+ stages :
3+ - clone
4+ - prepare
5+ - build
6+ - release
37steps :
4- build-step :
8+
9+ main_clone :
10+ title : ' Cloning main repository...'
11+ stage : clone
12+ type : git-clone
13+ repo : ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}
14+ revision : ${{CF_BRANCH}}
15+ git : ${{GIT_CONTEXT}}
16+
17+ prepare_env_vars :
18+ title : ' Preparing environment variables...'
19+ stage : prepare
20+ image : codefreshio/ci-helpers
21+ working_directory : ${{main_clone}}
22+ commands :
23+ - cf_export DOCKER_VERSION=18.09.5
24+ - cf_export SERVICE_VERSION=$(yq r service.yaml version)
25+ - cf_export IMAGE_NAME=codefresh/dind
26+
27+ validate_version :
28+ title : ' Validating the service version...'
29+ stage : prepare
30+ image : codefreshio/ci-helpers
31+ fail_fast : false
32+ commands :
33+ - |
34+ err() { echo -e "\e[31m$@\e[0m" ; return 1 ; }
35+ ok() { echo -e "\e[32m$@\e[0m" ; return 0 ; }
36+
37+ current_version=${SERVICE_VERSION}
38+ last_version=$(git describe --abbrev=0 --tags)
39+ echo "Current version is $current_version, last version - $last_version"
40+ semver-cli greater $current_version $last_version && ok "Version check ok" || err "Please the update the version in the service.yaml file"
41+
42+ build_image :
43+ title : " Building the image..."
44+ stage : build
545 type : build
6- image-name : codefresh/dind
46+ working_directory : ${{main_clone}}
47+ build_arguments :
48+ - DOCKER_VERSION=${{DOCKER_VERSION}}
49+ dockerfile : ./Dockerfile
50+ image_name : ${{IMAGE_NAME}}
51+ tag : ${{CF_BRANCH_TAG_NORMALIZED}}
52+
53+ approve_existing_version_update :
54+ type : pending-approval
55+ stage : release
56+ title : " Are you sure you want to update already existing image version?"
57+ description : |
58+ "Used for reverting changes without raising the service version"
59+ when :
60+ branch :
61+ only : [master]
62+ steps :
63+ - name : validate_version
64+ on :
65+ - failure
66+
67+ release :
68+ type : parallel
69+ stage : release
70+ steps :
771
8- push to registry :
9- type : push
10- candidate : ${{build-step}}
11- tag : ${{CF_BRANCH}}
72+ add_git_tag :
73+ title : " Adding Git tag..."
74+ stage : release
75+ image : codefreshio/ci-helpers
76+ commands :
77+ - source /get-token/get-gh-token.sh
78+ - |
79+ curl --fail -X POST -d '{"ref": "refs/tags/${{SERVICE_VERSION}}","sha": "${{CF_REVISION}}"}' -H "Content-Type: application/json" -H "Authorization: token ${GITHUB_TOKEN}" https://api.github.com/repos/${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}/git/refs
80+ when :
81+ branch :
82+ only : [master]
83+ steps :
84+ - name : validate_version
85+ on :
86+ - success
87+
88+ push_image_prod :
89+ type : push
90+ title : " Pushing the image to the public registry..."
91+ stage : release
92+ image_name : ' ${{IMAGE_NAME}}'
93+ registry : " ${{REGISTRY_INTEGRATION}}"
94+ candidate : " ${{build_image}}"
95+ tags :
96+ - " ${{DOCKER_VERSION}}-v${{SERVICE_VERSION}}"
97+ - " latest"
98+ when :
99+ branch :
100+ only : [master]
0 commit comments