Skip to content

Commit 7af420c

Browse files
Add service.yaml; and codefresh.yml (#34) SAAS-5071
1 parent 52c5d8b commit 7af420c

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

codefresh.yml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
version: "1.0"
2+
stages:
3+
- clone
4+
- prepare
5+
- build
6+
- release
7+
steps:
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 SERVICE_VERSION=$(yq r service.yaml version)
24+
- cf_export IMAGE_NAME=codefresh/cf-deploy-kubernetes
25+
26+
validate_version:
27+
title: 'Validating the service version...'
28+
stage: prepare
29+
image: codefreshio/ci-helpers
30+
fail_fast: false
31+
commands:
32+
- |
33+
err() { echo -e "\e[31m$@\e[0m" ; return 1 ; }
34+
ok() { echo -e "\e[32m$@\e[0m" ; return 0 ; }
35+
36+
current_version=${SERVICE_VERSION}
37+
last_version=$(git describe --abbrev=0 --tags)
38+
echo "Current version is $current_version, last version - $last_version"
39+
semver-cli greater $current_version $last_version && ok "Version check ok" || err "Please the update the version in the service.yaml file"
40+
41+
build_image:
42+
title: "Building the image..."
43+
stage: build
44+
type: build
45+
working_directory: ${{main_clone}}
46+
dockerfile: ./Dockerfile
47+
build_arguments:
48+
- COMPOSE_VERSION=${{COMPOSE_VERSION}}
49+
image_name: ${{IMAGE_NAME}}
50+
tag: ${{CF_BRANCH_TAG_NORMALIZED}}
51+
52+
approve_existing_version_update:
53+
type: pending-approval
54+
stage: release
55+
title: "Are you sure you want to update already existing image version?"
56+
description: |
57+
"Used for reverting changes without raising the service version"
58+
when:
59+
branch:
60+
only: [master]
61+
steps:
62+
- name: validate_version
63+
on:
64+
- failure
65+
66+
release:
67+
type: parallel
68+
stage: release
69+
steps:
70+
71+
add_git_tag:
72+
title: "Adding Git tag..."
73+
stage: release
74+
image: codefreshio/ci-helpers
75+
commands:
76+
- source /get-token/get-gh-token.sh
77+
- |
78+
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
79+
when:
80+
branch:
81+
only: [master]
82+
steps:
83+
- name: validate_version
84+
on:
85+
- success
86+
87+
push_image_prod:
88+
type: push
89+
title: "Pushing the image to the public registry..."
90+
stage: release
91+
image_name: '${{IMAGE_NAME}}'
92+
registry: "${{REGISTRY_INTEGRATION}}"
93+
candidate: "${{build_image}}"
94+
tags:
95+
- "${{SERVICE_VERSION}}"
96+
- "latest"
97+
when:
98+
branch:
99+
only: [master]

service.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version: 16.1.0

0 commit comments

Comments
 (0)