-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathorb.yml
100 lines (91 loc) · 3.06 KB
/
orb.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
version: 2.1
description: "Assigns environmental variable dependant on if we are running on main branch, tag or another branch"
commands:
set-env:
parameters:
git-branch:
type: string
default: ""
git-tag:
type: string
default: ""
main-branch-name:
type: string
default: master
env-name-tag:
type: string
default: prod
env-name-main-branch:
type: string
default: nonprod
env-name-other-branch:
type: string
default: sandbox
environment-variable:
type: string
default: ENVIRONMENT
description: Set which environment we are in to environment variable << parameters.environment-variable>>
steps:
- when:
condition:
and:
- not: << parameters.git-tag >>
- not:
equal: [<< parameters.main-branch-name >>, << parameters.git-branch >>]
steps:
- run:
name: "Other Branch: Set << parameters.environment-variable >> to << parameters.env-name-other-branch >>"
command: echo 'export << parameters.environment-variable >>=<< parameters.env-name-other-branch >>' >> $BASH_ENV
- when:
condition:
equal: [<< parameters.main-branch-name >>, << parameters.git-branch >>]
steps:
- run:
name: "Main Branch: Set << parameters.environment-variable >> to << parameters.env-name-main-branch >>"
command: echo 'export << parameters.environment-variable >>=<< parameters.env-name-main-branch >>' >> $BASH_ENV
- when:
condition: << parameters.git-tag >>
steps:
- run:
name: "Tag: Set << parameters.environment-variable >> to << parameters.env-name-tag >>"
command: echo 'export << parameters.environment-variable >>=<< parameters.env-name-tag >>' >> $BASH_ENV
examples:
bare-bones:
description: Simply pass git branch and git tag
usage:
version: 2.1
orbs:
env-orb: ovotech/set-current-environment@1
jobs:
set-environment:
executor: any
steps:
- env-orb/set-env:
git-branch: << pipeline.git.branch >>
git-tag: << pipeline.git.tag >>
workflows:
test:
jobs:
- set-environment
full-parameters:
description: all parameters set
usage:
version: 2.1
orbs:
env-orb: ovotech/set-current-environment@1
jobs:
set-environment:
executor: any
steps:
- env-orb/set-env:
git-branch: << pipeline.git.branch >>
git-tag: << pipeline.git.tag >>
main-branch-name: main
env-name-tag: tag-name
env-name-main-branch: main-name
env-name-other-branch: other-name
environment-variable: PROFILE
workflows:
test:
jobs:
- set-environment