antelope-cli 1.2.3 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/ansible/onboarding-ca/README.md +105 -105
  2. package/ansible/onboarding-ca/onboard-ca.yml +43 -51
  3. package/ansible/onboarding-ca/requirements.yml +8 -8
  4. package/ansible/onboarding-ca/roles/onboard_ca/defaults/main.yml +77 -49
  5. package/ansible/onboarding-ca/roles/onboard_ca/meta/main.yml +10 -10
  6. package/ansible/onboarding-ca/roles/onboard_ca/tasks/main.yml +311 -193
  7. package/ansible/onboarding-ca/roles/onboard_ca/tasks/per_branch.yml +114 -107
  8. package/ansible/onboarding-ca/roles/onboard_ca/vars/main.yml +9 -9
  9. package/ansible/onboarding-crm/README.md +107 -0
  10. package/ansible/onboarding-crm/onboard-crm.yml +57 -0
  11. package/ansible/onboarding-crm/requirements.yml +8 -0
  12. package/ansible/onboarding-crm/roles/onboard_crm/defaults/main.yml +98 -0
  13. package/ansible/onboarding-crm/roles/onboard_crm/meta/main.yml +10 -0
  14. package/ansible/onboarding-crm/roles/onboard_crm/tasks/main.yml +357 -0
  15. package/ansible/onboarding-crm/roles/onboard_crm/tasks/per_branch.yml +138 -0
  16. package/ansible/onboarding-crm/roles/onboard_crm/vars/main.yml +9 -0
  17. package/index.js +12 -12
  18. package/onboarding/brand.js +21 -21
  19. package/onboarding/createConfig.js +71 -71
  20. package/onboarding/favicon.js +24 -24
  21. package/onboarding/index.js +62 -62
  22. package/onboarding/logo.js +16 -16
  23. package/onboarding/themes.js +92 -92
  24. package/onboarding/translations.js +41 -41
  25. package/onboarding/variablesColors.js +58 -58
  26. package/onboarding-ca/brand.js +13 -13
  27. package/onboarding-ca/index.js +94 -94
  28. package/onboarding-ca/riskDisclaimer.js +27 -27
  29. package/onboarding-ca/scss.js +24 -24
  30. package/onboarding-ca/templates/risk-disclaimer.html +12 -12
  31. package/onboarding-crm/brand.js +22 -22
  32. package/onboarding-crm/brandLogos.js +31 -0
  33. package/onboarding-crm/createConfig.js +47 -40
  34. package/onboarding-crm/index.js +181 -171
  35. package/onboarding-crm/themes.js +92 -92
  36. package/onboarding-crm/variablesColors.js +53 -53
  37. package/package.json +30 -30
@@ -0,0 +1,357 @@
1
+ ---
2
+ # --- Resolve secrets: prefer the provided value, else fall back to 1Password (op CLI) ---
3
+ # The op fallback needs a signed-in `op` on the control node (op signin, or
4
+ # OP_SERVICE_ACCOUNT_TOKEN). A missing/failed op is tolerated here; the validate step
5
+ # below reports the still-empty token with a clear message.
6
+ - name: Fetch the Bitbucket API token from 1Password
7
+ when: (bitbucket_token | default('') | length) == 0
8
+ ansible.builtin.command:
9
+ argv:
10
+ - op
11
+ - item
12
+ - get
13
+ - "{{ onepassword_bitbucket_item }}"
14
+ - "--vault"
15
+ - "{{ onepassword_vault }}"
16
+ - "--fields"
17
+ - "label={{ onepassword_bitbucket_field }}"
18
+ - "--reveal"
19
+ register: op_bitbucket
20
+ changed_when: false
21
+ failed_when: false
22
+ no_log: true
23
+
24
+ - name: Adopt the 1Password Bitbucket token
25
+ when:
26
+ - (bitbucket_token | default('') | length) == 0
27
+ - op_bitbucket is not skipped
28
+ - (op_bitbucket.rc | default(1)) == 0
29
+ - (op_bitbucket.stdout | default('') | length) > 0
30
+ ansible.builtin.set_fact:
31
+ bitbucket_token: "{{ op_bitbucket.stdout | trim }}"
32
+ no_log: true
33
+
34
+ # Consul token is only needed when destination branches are derived (no dest_branches override).
35
+ - name: Resolve the Consul token from the environment
36
+ when: (consul_token | default('') | length) == 0
37
+ ansible.builtin.set_fact:
38
+ consul_token: "{{ lookup('env', 'CONSUL_HTTP_TOKEN') }}"
39
+ no_log: true
40
+
41
+ - name: Fetch the Consul token from 1Password
42
+ when:
43
+ - (consul_token | default('') | length) == 0
44
+ - (dest_branches | default('') | length) == 0
45
+ ansible.builtin.command:
46
+ argv:
47
+ - op
48
+ - item
49
+ - get
50
+ - "{{ onepassword_consul_item }}"
51
+ - "--vault"
52
+ - "{{ onepassword_vault }}"
53
+ - "--fields"
54
+ - "label={{ onepassword_consul_field }}"
55
+ - "--reveal"
56
+ register: op_consul
57
+ changed_when: false
58
+ failed_when: false
59
+ no_log: true
60
+
61
+ - name: Adopt the 1Password Consul token
62
+ when:
63
+ - (consul_token | default('') | length) == 0
64
+ - op_consul is not skipped
65
+ - (op_consul.rc | default(1)) == 0
66
+ - (op_consul.stdout | default('') | length) > 0
67
+ ansible.builtin.set_fact:
68
+ consul_token: "{{ op_consul.stdout | trim }}"
69
+ no_log: true
70
+
71
+ - name: Validate required inputs
72
+ ansible.builtin.assert:
73
+ that:
74
+ - antelope_id is defined and (antelope_id | length) > 0
75
+ - brand_name is defined and (brand_name | length) > 0
76
+ - jira_key_crm_branding is defined and (jira_key_crm_branding | length) > 0
77
+ - logo_url is defined and (logo_url | length) > 0
78
+ - languages is defined and (languages | length) > 0
79
+ - crm_type is defined and (crm_type | length) > 0
80
+ - crm_type in allowed_crm_types
81
+ - bitbucket_token is defined and (bitbucket_token | length) > 0
82
+ - bitbucket_email is defined and (bitbucket_email | length) > 0
83
+ fail_msg: >-
84
+ Required: antelope_id, brand_name, jira_key_crm_branding, logo_url, languages, crm_type (one of {{ allowed_crm_types | join(', ') }}), bitbucket_email.
85
+ bitbucket_token must be provided (via --extra-vars / prompt) or resolvable from 1Password
86
+ item '{{ onepassword_bitbucket_item }}' field '{{ onepassword_bitbucket_field }}' (op signin).
87
+
88
+ # The CRM CLI keys everything off the Antelope ID (connectedBrandName); normalize it the same
89
+ # way the CLI does (lowercase, no spaces) so the branch name / assets folder match the repo.
90
+ - name: Normalize the brand id
91
+ ansible.builtin.set_fact:
92
+ antelope_id_norm: "{{ antelope_id | lower | regex_replace(' ', '') }}"
93
+
94
+ # languages may arrive as a YAML list (brand_vars) or a CSV string (prompt / extra-var);
95
+ # the CLI wants a comma-separated string.
96
+ - name: Normalize languages to a CSV string
97
+ ansible.builtin.set_fact:
98
+ languages_csv: "{{ (languages | join(',')) if (languages is not string) else languages }}"
99
+
100
+ # --- Destination branches: derived from the release train in Consul ------------------
101
+ # develop is always onboarded. master-<version/prod> tracks the live release; while a new
102
+ # release is staged (version/staging != version/prod) its master-<version/staging> exists
103
+ # too and is onboarded as well. Once staging == prod (the release has shipped) there is a
104
+ # single master branch. An explicit dest_branches extra-var bypasses the lookup entirely.
105
+ - name: Resolve destination branches from Consul
106
+ when: (dest_branches | default('') | length) == 0
107
+ block:
108
+ - name: Consul token is required to derive destination branches
109
+ ansible.builtin.assert:
110
+ that:
111
+ - consul_token is defined and (consul_token | length) > 0
112
+ fail_msg: >-
113
+ consul_token is required to read version/prod and version/staging. Provide it via
114
+ -e consul_token=..., $CONSUL_HTTP_TOKEN, or 1Password item '{{ onepassword_consul_item }}'
115
+ (op signin); or pass -e dest_branches=develop,master-XX.Y to bypass the Consul lookup.
116
+
117
+ - name: Read the prod release version from Consul
118
+ ansible.builtin.uri:
119
+ url: "{{ consul_url }}/v1/kv/version/prod?raw=1"
120
+ headers:
121
+ X-Consul-Token: "{{ consul_token }}"
122
+ return_content: true
123
+ register: consul_prod
124
+
125
+ - name: Read the staging release version from Consul
126
+ ansible.builtin.uri:
127
+ url: "{{ consul_url }}/v1/kv/version/staging?raw=1"
128
+ headers:
129
+ X-Consul-Token: "{{ consul_token }}"
130
+ return_content: true
131
+ register: consul_staging
132
+
133
+ - name: Derive the destination branch list from the release versions
134
+ ansible.builtin.set_fact:
135
+ dest_branch_list: >-
136
+ {{ ['develop', 'master-' + (consul_prod.content | trim)]
137
+ + (['master-' + (consul_staging.content | trim)]
138
+ if (consul_staging.content | trim) != (consul_prod.content | trim) else []) }}
139
+
140
+ - name: Normalize destination branch list (explicit override)
141
+ when: (dest_branches | default('') | length) > 0
142
+ ansible.builtin.set_fact:
143
+ dest_branch_list: "{{ dest_branches.split(',') | map('trim') | reject('equalto', '') | list }}"
144
+
145
+ - name: Show the resolved destination branches
146
+ ansible.builtin.debug:
147
+ msg: "Destination branches: {{ dest_branch_list }}"
148
+
149
+ # --- Jira Fix Version: DangerJS fails any web-crm PR whose linked issue has no
150
+ # Fix Version, so stamp the release version (V<version/prod>) on the ticket BEFORE the
151
+ # branches are pushed. Non-fatal — a missing token / unmatched version warns and skips.
152
+ - name: Set the Jira Fix Version on the branding ticket
153
+ when: manage_jira_fix_version | bool
154
+ block:
155
+ - name: Fetch the Jira token from 1Password
156
+ when: (jira_token | default('') | length) == 0
157
+ ansible.builtin.command:
158
+ argv:
159
+ - op
160
+ - item
161
+ - get
162
+ - "{{ onepassword_jira_item }}"
163
+ - "--vault"
164
+ - "{{ onepassword_vault }}"
165
+ - "--fields"
166
+ - "label={{ onepassword_jira_field }}"
167
+ - "--reveal"
168
+ register: op_jira
169
+ changed_when: false
170
+ failed_when: false
171
+ no_log: true
172
+
173
+ - name: Adopt the 1Password Jira token
174
+ when:
175
+ - (jira_token | default('') | length) == 0
176
+ - op_jira is not skipped
177
+ - (op_jira.rc | default(1)) == 0
178
+ - (op_jira.stdout | default('') | length) > 0
179
+ ansible.builtin.set_fact:
180
+ jira_token: "{{ op_jira.stdout | trim }}"
181
+ no_log: true
182
+
183
+ # master-<ver> / release-<ver> destination branches → Fix Version names (e.g. V27.0).
184
+ - name: Derive the release Fix Version name(s)
185
+ ansible.builtin.set_fact:
186
+ jira_fix_versions: >-
187
+ {{ dest_branch_list
188
+ | select('match', '^(master|release)-')
189
+ | map('regex_replace', '^(master|release)-', jira_version_prefix)
190
+ | list | unique }}
191
+
192
+ - name: Warn when the Fix Version cannot be set
193
+ when: (jira_token | default('') | length) == 0 or (jira_fix_versions | length) == 0
194
+ ansible.builtin.debug:
195
+ msg: >-
196
+ Skipping Jira Fix Version ({{ 'no jira_token — provide -e jira_token= or 1Password item '
197
+ ~ onepassword_jira_item if (jira_token | default('') | length) == 0
198
+ else 'no master-<ver> destination branch to derive the version from' }}).
199
+ DangerJS will fail until a Fix Version is set on {{ jira_key_crm_branding }}.
200
+
201
+ - name: Look up the Jira project versions
202
+ when:
203
+ - (jira_token | default('') | length) > 0
204
+ - (jira_fix_versions | length) > 0
205
+ ansible.builtin.uri:
206
+ url: "{{ jira_base_url }}/rest/api/2/project/{{ jira_project_key }}/versions"
207
+ url_username: "{{ jira_email }}"
208
+ url_password: "{{ jira_token }}"
209
+ force_basic_auth: true
210
+ return_content: true
211
+ register: jira_versions
212
+ failed_when: false
213
+ no_log: true
214
+
215
+ - name: Map Fix Version name(s) to id(s)
216
+ when:
217
+ - jira_versions is defined
218
+ - (jira_versions.status | default(0)) == 200
219
+ ansible.builtin.set_fact:
220
+ jira_fix_version_ids: >-
221
+ {{ jira_versions.json
222
+ | selectattr('name', 'in', jira_fix_versions)
223
+ | map(attribute='id')
224
+ | map('community.general.dict_kv', 'id')
225
+ | list }}
226
+
227
+ - name: Report Fix Version names not found in the project
228
+ when:
229
+ - jira_versions is defined
230
+ - (jira_versions.status | default(0)) == 200
231
+ - (jira_fix_version_ids | default([]) | length) < (jira_fix_versions | length)
232
+ ansible.builtin.debug:
233
+ msg: >-
234
+ Some Fix Version name(s) in {{ jira_fix_versions }} do not exist in project
235
+ {{ jira_project_key }} — create them in Jira first. Setting only the matched ones.
236
+
237
+ # Additive (keeps any existing fixVersions); Jira dedups by id, so re-runs are idempotent.
238
+ - name: Set the Fix Version on {{ jira_key_crm_branding }}
239
+ when: (jira_fix_version_ids | default([]) | length) > 0
240
+ ansible.builtin.uri:
241
+ url: "{{ jira_base_url }}/rest/api/2/issue/{{ jira_key_crm_branding }}"
242
+ method: PUT
243
+ url_username: "{{ jira_email }}"
244
+ url_password: "{{ jira_token }}"
245
+ force_basic_auth: true
246
+ body_format: json
247
+ body:
248
+ update:
249
+ fixVersions: "{{ jira_fix_version_ids | map('community.general.dict_kv', 'add') | list }}"
250
+ status_code: [204]
251
+ register: jira_fixver_set
252
+ failed_when: false
253
+ no_log: true
254
+
255
+ - name: Confirm the Fix Version result
256
+ ansible.builtin.debug:
257
+ msg: >-
258
+ {{ 'Set Fix Version ' ~ jira_fix_versions | join(', ') ~ ' on ' ~ jira_key_crm_branding
259
+ if (jira_fixver_set.status | default(0)) == 204
260
+ else 'Fix Version not set (HTTP ' ~ (jira_fixver_set.status | default('n/a')) ~ ')' }}
261
+ when: jira_fixver_set is defined and (jira_fixver_set is not skipped)
262
+
263
+ # --- Reviewers: pull from the repo's Bitbucket default-reviewers config -------------
264
+ - name: Resolve reviewers from repo default-reviewers config
265
+ when: (reviewers | length) == 0
266
+ block:
267
+ - name: Identify the authenticating Bitbucket account (PR author)
268
+ ansible.builtin.uri:
269
+ url: "{{ api_base }}/user"
270
+ url_username: "{{ bitbucket_email }}"
271
+ url_password: "{{ bitbucket_token }}"
272
+ force_basic_auth: true
273
+ return_content: true
274
+ register: bb_user
275
+
276
+ - name: Fetch the repository default reviewers
277
+ ansible.builtin.uri:
278
+ url: "{{ api_base }}/repositories/{{ workspace }}/{{ repo_slug }}/default-reviewers?pagelen=100"
279
+ url_username: "{{ bitbucket_email }}"
280
+ url_password: "{{ bitbucket_token }}"
281
+ force_basic_auth: true
282
+ return_content: true
283
+ register: bb_default_reviewers
284
+
285
+ # Bitbucket rejects a PR whose author is also a reviewer, so drop the authenticating account.
286
+ # The REST API does not auto-apply default reviewers, so we pass them explicitly.
287
+ # Bitbucket's PR-create reviewers array is keyed by uuid; exclude the author by account_id.
288
+ # Built in a single expression (not an accumulating set_fact loop, which is nondeterministic).
289
+ - name: Build reviewers list (excluding the PR author)
290
+ ansible.builtin.set_fact:
291
+ reviewers: >-
292
+ {{ bb_default_reviewers.json['values']
293
+ | rejectattr('account_id', 'equalto', bb_user.json.account_id)
294
+ | map(attribute='uuid')
295
+ | map('community.general.dict_kv', 'uuid')
296
+ | list }}
297
+
298
+ - name: Ensure clone parent directory exists
299
+ ansible.builtin.file:
300
+ path: "{{ work_dir | dirname }}"
301
+ state: directory
302
+ mode: "0755"
303
+
304
+ - name: Clone / refresh web-crm over SSH
305
+ ansible.builtin.git:
306
+ repo: "{{ repo_ssh_url }}"
307
+ dest: "{{ work_dir }}"
308
+ version: "{{ dest_branch_list[0] }}"
309
+ update: true
310
+ force: true
311
+ accept_hostkey: true
312
+
313
+ - name: Onboard the brand on each destination branch
314
+ ansible.builtin.include_tasks: per_branch.yml
315
+ loop: "{{ dest_branch_list }}"
316
+ loop_control:
317
+ loop_var: dest_branch
318
+
319
+ - name: Summary of pull requests
320
+ ansible.builtin.debug:
321
+ msg: "{{ pr_results | default([]) }}"
322
+
323
+ # --- Consul: publish the generated configs.ts to the brand's crm_env KV --------------
324
+ # configs.ts is gitignored (not committed) — it is the env's CRM config, so push it to Consul
325
+ # (Antelope/<brand>/crm_env) in addition to the PR body. Non-fatal: warns if the token lacks write.
326
+ - name: Read generated configs.ts for Consul crm_env
327
+ when: manage_consul_crm_env | default(true) | bool
328
+ ansible.builtin.slurp:
329
+ src: "{{ work_dir }}/src/configs/configs.ts"
330
+ register: crm_configs_ts_final
331
+ failed_when: false
332
+
333
+ - name: Update Consul crm_env with the generated configs.ts
334
+ when:
335
+ - manage_consul_crm_env | default(true) | bool
336
+ - crm_configs_ts_final is not skipped
337
+ - (crm_configs_ts_final.content | default('') | length) > 0
338
+ - (consul_token | default('') | length) > 0
339
+ ansible.builtin.uri:
340
+ url: "{{ consul_url }}/v1/kv/{{ crm_env_consul_key }}"
341
+ method: PUT
342
+ headers:
343
+ X-Consul-Token: "{{ consul_token }}"
344
+ body: "{{ crm_configs_ts_final.content | b64decode }}"
345
+ status_code: [200]
346
+ register: consul_crm_env_put
347
+ failed_when: false
348
+ no_log: false
349
+
350
+ - name: Confirm the Consul crm_env update
351
+ when: manage_consul_crm_env | default(true) | bool and (consul_crm_env_put is defined)
352
+ ansible.builtin.debug:
353
+ msg: >-
354
+ {{ 'Updated Consul ' ~ crm_env_consul_key
355
+ if (consul_crm_env_put.status | default(0)) == 200
356
+ else 'Consul crm_env NOT updated (HTTP ' ~ (consul_crm_env_put.status | default('n/a'))
357
+ ~ ') - token may lack write on ' ~ crm_env_consul_key }}
@@ -0,0 +1,138 @@
1
+ ---
2
+ # Runs once per destination branch. `dest_branch` is the loop var.
3
+
4
+ - name: "[{{ dest_branch }}] Compose source branch name"
5
+ ansible.builtin.set_fact:
6
+ branch_prefix: "{{ 'hotfix' if dest_branch is match('(master|release)') else 'feature' }}"
7
+
8
+ # Suffix the release version onto master/release targets so each destination gets its OWN
9
+ # source branch. Without it, master-27.0 and master-27.1 (both present during a staged
10
+ # release, e.g. after a code freeze) collapse to one hotfix branch → the 2nd PR reuses the
11
+ # 1st's branch (wrong base) and close_source_branch on either merge kills the other PR.
12
+ - name: "[{{ dest_branch }}] Set source branch"
13
+ ansible.builtin.set_fact:
14
+ source_branch: >-
15
+ {{ branch_prefix }}/{{ jira_key_crm_branding }}-onboarding-crm-{{ antelope_id_norm }}{{
16
+ ('-' ~ (dest_branch | regex_replace('^(master|release)-', '')))
17
+ if dest_branch is match('(master|release)') else '' }}
18
+
19
+ - name: "[{{ dest_branch }}] Fetch all remote branches"
20
+ ansible.builtin.command:
21
+ cmd: git fetch origin --prune
22
+ chdir: "{{ work_dir }}"
23
+ changed_when: false
24
+
25
+ - name: "[{{ dest_branch }}] Does the source branch already exist on origin?"
26
+ ansible.builtin.command:
27
+ cmd: "git ls-remote --exit-code --heads origin {{ source_branch }}"
28
+ chdir: "{{ work_dir }}"
29
+ register: remote_src
30
+ failed_when: false
31
+ changed_when: false
32
+
33
+ # Base the working branch on its own remote head if it already exists (idempotent re-run),
34
+ # otherwise on the destination branch.
35
+ - name: "[{{ dest_branch }}] Check out the working branch"
36
+ ansible.builtin.command:
37
+ cmd: >-
38
+ git checkout -B {{ source_branch }}
39
+ {{ ('origin/' + source_branch) if remote_src.rc == 0 else ('origin/' + dest_branch) }}
40
+ chdir: "{{ work_dir }}"
41
+
42
+ # Required flags always passed; --color and --base_url are optional (blank => CLI defaults:
43
+ # $corp palette and the dev baseUrl). argv is built as a list so no shell quoting is involved.
44
+ - name: "[{{ dest_branch }}] Generate brand files via antelope-cli"
45
+ ansible.builtin.command:
46
+ argv: >-
47
+ {{ ['npx', 'antelope-cli@' ~ antelope_cli_version, 'onboarding-crm',
48
+ '--brand_id', antelope_id_norm,
49
+ '--brand_name', brand_name,
50
+ '--logo_url', logo_url,
51
+ '--languages', languages_csv,
52
+ '--type', crm_type,
53
+ '--affiliates_api_url', affiliates_api_url,
54
+ '--arctic_brand', (arctic_brand | default(false) | string | lower)]
55
+ + (['--color', color] if (color | default('') | length) > 0 else [])
56
+ + (['--base_url', base_url] if (base_url | default('') | length) > 0 else []) }}
57
+ chdir: "{{ work_dir }}"
58
+ environment:
59
+ CI: "true"
60
+ changed_when: true
61
+
62
+ - name: "[{{ dest_branch }}] Read generated configs.ts (gitignored) for the PR body / Consul"
63
+ ansible.builtin.slurp:
64
+ src: "{{ work_dir }}/src/configs/configs.ts"
65
+ register: crm_configs_ts
66
+ failed_when: false
67
+
68
+ - name: "[{{ dest_branch }}] Compose PR description (ticket + configs.ts for Consul copy-paste)"
69
+ ansible.builtin.set_fact:
70
+ pr_description: |-
71
+ {{ jira_key_crm_branding }}: On-Boarding {{ brand_name }} CRM Branding
72
+
73
+ configs.ts — copy into Consul `{{ crm_env_consul_key }}`:
74
+
75
+ ```ts
76
+ {{ crm_configs_ts.content | default('') | b64decode }}
77
+ ```
78
+
79
+ - name: "[{{ dest_branch }}] Stage changes"
80
+ ansible.builtin.command:
81
+ cmd: git add -A
82
+ chdir: "{{ work_dir }}"
83
+ changed_when: false
84
+
85
+ - name: "[{{ dest_branch }}] Detect staged changes"
86
+ ansible.builtin.command:
87
+ cmd: git diff --cached --quiet
88
+ chdir: "{{ work_dir }}"
89
+ register: staged
90
+ failed_when: false
91
+ changed_when: false
92
+
93
+ - name: "[{{ dest_branch }}] Commit"
94
+ ansible.builtin.command:
95
+ cmd: >-
96
+ git -c user.name="{{ git_user_name }}" -c user.email="{{ git_user_email }}"
97
+ commit -m "{{ jira_key_crm_branding }}: On-Boarding {{ brand_name }} CRM Branding"
98
+ chdir: "{{ work_dir }}"
99
+ when: staged.rc == 1
100
+
101
+ - name: "[{{ dest_branch }}] Push source branch"
102
+ ansible.builtin.command:
103
+ cmd: "git push -u origin {{ source_branch }}"
104
+ chdir: "{{ work_dir }}"
105
+ when: staged.rc == 1
106
+
107
+ - name: "[{{ dest_branch }}] Open pull request"
108
+ ansible.builtin.uri:
109
+ url: "{{ api_base }}/repositories/{{ workspace }}/{{ repo_slug }}/pullrequests"
110
+ method: POST
111
+ url_username: "{{ bitbucket_email }}"
112
+ url_password: "{{ bitbucket_token }}"
113
+ force_basic_auth: true
114
+ body_format: json
115
+ body:
116
+ title: "{{ jira_key_crm_branding }}: On-Boarding {{ brand_name }} CRM Branding"
117
+ description: "{{ pr_description }}"
118
+ source:
119
+ branch:
120
+ name: "{{ source_branch }}"
121
+ destination:
122
+ branch:
123
+ name: "{{ dest_branch }}"
124
+ reviewers: "{{ reviewers }}"
125
+ close_source_branch: true
126
+ return_content: true
127
+ status_code: [201, 400] # 400 tolerated: a PR for this source->dest already exists
128
+ register: pr_response
129
+
130
+ - name: "[{{ dest_branch }}] Record PR result"
131
+ ansible.builtin.set_fact:
132
+ pr_results: >-
133
+ {{ (pr_results | default([])) + [{
134
+ 'destination': dest_branch,
135
+ 'source': source_branch,
136
+ 'status': pr_response.status,
137
+ 'url': (pr_response.json.links.html.href | default('(already exists or not created)'))
138
+ }] }}
@@ -0,0 +1,9 @@
1
+ ---
2
+ # Constants — the target repository for CRM onboarding.
3
+ api_base: "https://api.bitbucket.org/2.0"
4
+ workspace: "xsitesinc"
5
+ repo_slug: "web-crm"
6
+ repo_ssh_url: "git@bitbucket.org:xsitesinc/web-crm.git"
7
+
8
+ # Consul (v2 cluster) — source of the release train used to derive destination branches.
9
+ consul_url: "https://consul.xsites.xyz"
package/index.js CHANGED
@@ -1,12 +1,12 @@
1
- #!/usr/bin/env node
2
- const args = process.argv.slice(2);
3
-
4
- if (args[0] === "onboarding") {
5
- require('./onboarding');
6
- } else if (args[0] === "onboarding-ca") {
7
- require('./onboarding-ca');
8
- } else if (args[0] === "onboarding-crm") {
9
- require('./onboarding-crm');
10
- } else {
11
- console.log("Unknown command");
12
- }
1
+ #!/usr/bin/env node
2
+ const args = process.argv.slice(2);
3
+
4
+ if (args[0] === "onboarding") {
5
+ require('./onboarding');
6
+ } else if (args[0] === "onboarding-ca") {
7
+ require('./onboarding-ca');
8
+ } else if (args[0] === "onboarding-crm") {
9
+ require('./onboarding-crm');
10
+ } else {
11
+ console.log("Unknown command");
12
+ }
@@ -1,21 +1,21 @@
1
- let brand = {
2
- brandName: '',
3
- kebabCaseName: '',
4
- connectedBrandName: '',
5
- color: '',
6
- languages: null,
7
- favicon: '',
8
- type: '',
9
- FCMSenderId: '',
10
- logo: ''
11
- };
12
-
13
- function updateBrand(updatedBrand) {
14
- brand = { ...brand, ...updatedBrand };
15
- }
16
-
17
- function getBrand() {
18
- return brand;
19
- }
20
-
21
- module.exports = { updateBrand, getBrand };
1
+ let brand = {
2
+ brandName: '',
3
+ kebabCaseName: '',
4
+ connectedBrandName: '',
5
+ color: '',
6
+ languages: null,
7
+ favicon: '',
8
+ type: '',
9
+ FCMSenderId: '',
10
+ logo: ''
11
+ };
12
+
13
+ function updateBrand(updatedBrand) {
14
+ brand = { ...brand, ...updatedBrand };
15
+ }
16
+
17
+ function getBrand() {
18
+ return brand;
19
+ }
20
+
21
+ module.exports = { updateBrand, getBrand };