antelope-cli 1.2.0 → 1.2.1

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.
@@ -1,72 +1,72 @@
1
- # Client Area brand onboarding (Ansible)
2
-
3
- Automates onboarding a new client brand into
4
- [`web-client-area`](https://bitbucket.org/xsitesinc/web-client-area): it creates the brand
5
- assets and opens the pull request(s), reproducing the manual onboarding PRs
6
- (e.g. [#4266](https://bitbucket.org/xsitesinc/web-client-area/pull-requests/4266)).
7
-
8
- Per brand it creates, under the target repo:
9
-
10
- - `src/assets/other/<folder>/<folder>.scss` — empty stylesheet
11
- - `src/assets/other/<folder>/legal/risk-disclaimer.html` — the standard disclaimer
12
-
13
- The file creation is delegated to the `onboarding-ca` command of the published
14
- [`antelope-cli`](https://www.npmjs.com/package/antelope-cli) (`npx antelope-cli@<version> onboarding-ca`);
15
- this role owns cloning, branching, committing, pushing and PR creation.
16
-
17
- ## Preconditions (control node)
18
-
19
- - `git`, Node.js (engines `^16.20.2`) and `npx` on `PATH`.
20
- - An **SSH key authorized to push** to `xsitesinc/web-client-area` (push is over SSH).
21
- - A **Bitbucket API token** with pull-request write access (used only for the REST calls:
22
- reviewer lookup + PR creation). Store it in Ansible Vault or pass via environment — never commit it.
23
- - `ansible.builtin.uri` needs Python `urllib` (standard). No extra collections required.
24
-
25
- ## Usage
26
-
27
- Interactive (prompts for the inputs):
28
-
29
- ```bash
30
- ansible-playbook onboard-ca.yml
31
- ```
32
-
33
- Non-interactive (for CI / wrapping playbooks) — extra-vars skip the prompts:
34
-
35
- ```bash
36
- ansible-playbook onboard-ca.yml \
37
- -e brand_name="Zenith Horizon Group" \
38
- -e jira_key=ATLP-47067 \
39
- -e dest_branches=develop,master-26.9 \
40
- -e bitbucket_token="$BITBUCKET_TOKEN"
41
- ```
42
-
43
- ## Inputs
44
-
45
- | var | required | example | notes |
46
- |-----|----------|---------|-------|
47
- | `brand_name` | yes | `Zenith Horizon Group` | display name → PR title |
48
- | `jira_key` | yes | `ATLP-47067` | PR title prefix + branch name |
49
- | `dest_branches` | yes | `develop,master-26.9` | comma-separated; **one PR per branch** |
50
- | `bitbucket_token` | yes | *(secret)* | Bearer token for the REST calls |
51
- | `brand_assets_folder` | no | `zenithhorizongroup` | folder name → CLI `--brand_assets_folder`, branch name; prompted separately. Blank ⇒ derived from `brand_name` (lowercased, spaces removed) |
52
- | `reviewers` | no | *(auto)* | default: repo's Bitbucket default-reviewers (author excluded); override with `[{account_id: "..."}]` |
53
- | `antelope_cli_version` | no | `1.2.0` | pinned published CLI version |
54
- | `work_dir` | no | `/tmp/onboard-ca/web-client-area` | clone location |
55
- | `git_user_name` / `git_user_email` | no | | commit identity |
56
-
57
- ## Behavior notes
58
-
59
- - **One PR per destination branch.** `develop` → `feature/<jira>-onboarding-<folder>`;
60
- `master-*`/`release-*` → `hotfix/<jira>-onboarding-<folder>`. Each branch is based on its own
61
- destination so diverged histories don't bleed across PRs.
62
- - **Reviewers** are read from the repo's Bitbucket *Default reviewers* config; the authenticating
63
- account is excluded (Bitbucket rejects a PR whose author is a reviewer).
64
- - **Idempotent:** re-running with the same inputs recreates the (identical) files on the existing
65
- source branch, detects no staged changes, skips commit/push, and tolerates the "PR already exists"
66
- response (HTTP 400).
67
- - The playbook prints a summary of created PRs (destination, source branch, status, URL).
68
-
69
- ## Scope
70
-
71
- Client Area only. web-crm onboarding is a separate, independent process (its file edits live in
72
- antelope-cli's existing `onboarding` command) and is not run by this playbook.
1
+ # Client Area brand onboarding (Ansible)
2
+
3
+ Automates onboarding a new client brand into
4
+ [`web-client-area`](https://bitbucket.org/xsitesinc/web-client-area): it creates the brand
5
+ assets and opens the pull request(s), reproducing the manual onboarding PRs
6
+ (e.g. [#4266](https://bitbucket.org/xsitesinc/web-client-area/pull-requests/4266)).
7
+
8
+ Per brand it creates, under the target repo:
9
+
10
+ - `src/assets/other/<folder>/<folder>.scss` — empty stylesheet
11
+ - `src/assets/other/<folder>/legal/risk-disclaimer.html` — the standard disclaimer
12
+
13
+ The file creation is delegated to the `onboarding-ca` command of the published
14
+ [`antelope-cli`](https://www.npmjs.com/package/antelope-cli) (`npx antelope-cli@<version> onboarding-ca`);
15
+ this role owns cloning, branching, committing, pushing and PR creation.
16
+
17
+ ## Preconditions (control node)
18
+
19
+ - `git`, Node.js (engines `^16.20.2`) and `npx` on `PATH`.
20
+ - An **SSH key authorized to push** to `xsitesinc/web-client-area` (push is over SSH).
21
+ - A **Bitbucket API token** with pull-request write access (used only for the REST calls:
22
+ reviewer lookup + PR creation). Store it in Ansible Vault or pass via environment — never commit it.
23
+ - `ansible.builtin.uri` needs Python `urllib` (standard). No extra collections required.
24
+
25
+ ## Usage
26
+
27
+ Interactive (prompts for the inputs):
28
+
29
+ ```bash
30
+ ansible-playbook onboard-ca.yml
31
+ ```
32
+
33
+ Non-interactive (for CI / wrapping playbooks) — extra-vars skip the prompts:
34
+
35
+ ```bash
36
+ ansible-playbook onboard-ca.yml \
37
+ -e brand_name="Zenith Horizon Group" \
38
+ -e jira_key=ATLP-47067 \
39
+ -e dest_branches=develop,master-26.9 \
40
+ -e bitbucket_token="$BITBUCKET_TOKEN"
41
+ ```
42
+
43
+ ## Inputs
44
+
45
+ | var | required | example | notes |
46
+ |-----|----------|---------|-------|
47
+ | `brand_name` | yes | `Zenith Horizon Group` | display name → PR title |
48
+ | `jira_key` | yes | `ATLP-47067` | PR title prefix + branch name |
49
+ | `dest_branches` | yes | `develop,master-26.9` | comma-separated; **one PR per branch** |
50
+ | `bitbucket_token` | yes | *(secret)* | Bearer token for the REST calls |
51
+ | `brand_assets_folder` | no | `zenithhorizongroup` | folder name → CLI `--brand_assets_folder`, branch name; prompted separately. Blank ⇒ derived from `brand_name` (lowercased, spaces removed) |
52
+ | `reviewers` | no | *(auto)* | default: repo's Bitbucket default-reviewers (author excluded); override with `[{account_id: "..."}]` |
53
+ | `antelope_cli_version` | no | `1.2.0` | pinned published CLI version |
54
+ | `work_dir` | no | `/tmp/onboard-ca/web-client-area` | clone location |
55
+ | `git_user_name` / `git_user_email` | no | | commit identity |
56
+
57
+ ## Behavior notes
58
+
59
+ - **One PR per destination branch.** `develop` → `feature/<jira>-onboarding-<folder>`;
60
+ `master-*`/`release-*` → `hotfix/<jira>-onboarding-<folder>`. Each branch is based on its own
61
+ destination so diverged histories don't bleed across PRs.
62
+ - **Reviewers** are read from the repo's Bitbucket *Default reviewers* config; the authenticating
63
+ account is excluded (Bitbucket rejects a PR whose author is a reviewer).
64
+ - **Idempotent:** re-running with the same inputs recreates the (identical) files on the existing
65
+ source branch, detects no staged changes, skips commit/push, and tolerates the "PR already exists"
66
+ response (HTTP 400).
67
+ - The playbook prints a summary of created PRs (destination, source branch, status, URL).
68
+
69
+ ## Scope
70
+
71
+ Client Area only. web-crm onboarding is a separate, independent process (its file edits live in
72
+ antelope-cli's existing `onboarding` command) and is not run by this playbook.
@@ -1,41 +1,41 @@
1
- ---
2
- # Onboard a Client Area brand into web-client-area and open the PR(s).
3
- #
4
- # Interactive:
5
- # ansible-playbook onboard-ca.yml
6
- #
7
- # Non-interactive (e.g. from another playbook / CI), pass everything as extra-vars:
8
- # ansible-playbook onboard-ca.yml \
9
- # -e brand_name="Zenith Horizon Group" \
10
- # -e brand_assets_folder=zenithhorizongroup \
11
- # -e jira_key=ATLP-47067 \
12
- # -e dest_branches=develop,master-26.9 \
13
- # -e bitbucket_token="$BITBUCKET_TOKEN"
14
- #
15
- # Preconditions on the control node: git + Node (>=16) + npx, an SSH key authorized to
16
- # push to xsitesinc/web-client-area, and a Bitbucket API token with PR write access.
17
- - name: Onboard a Client Area brand (web-client-area)
18
- hosts: localhost
19
- connection: local
20
- gather_facts: false
21
-
22
- vars_prompt:
23
- - name: brand_name
24
- prompt: "Brand display name — used in the PR title (e.g. Zenith Horizon Group)"
25
- private: false
26
- - name: brand_assets_folder
27
- prompt: "Brand assets folder name — the src/assets/other/<folder> (e.g. zenithhorizongroup); leave blank to derive from the display name"
28
- default: ""
29
- private: false
30
- - name: jira_key
31
- prompt: "Jira key (e.g. ATLP-47067)"
32
- private: false
33
- - name: dest_branches
34
- prompt: "Destination branches, comma-separated (e.g. develop,master-26.9)"
35
- private: false
36
- - name: bitbucket_token
37
- prompt: "Bitbucket API token"
38
- private: true
39
-
40
- roles:
41
- - onboard_ca
1
+ ---
2
+ # Onboard a Client Area brand into web-client-area and open the PR(s).
3
+ #
4
+ # Interactive:
5
+ # ansible-playbook onboard-ca.yml
6
+ #
7
+ # Non-interactive (e.g. from another playbook / CI), pass everything as extra-vars:
8
+ # ansible-playbook onboard-ca.yml \
9
+ # -e brand_name="Zenith Horizon Group" \
10
+ # -e brand_assets_folder=zenithhorizongroup \
11
+ # -e jira_key=ATLP-47067 \
12
+ # -e dest_branches=develop,master-26.9 \
13
+ # -e bitbucket_token="$BITBUCKET_TOKEN"
14
+ #
15
+ # Preconditions on the control node: git + Node (>=16) + npx, an SSH key authorized to
16
+ # push to xsitesinc/web-client-area, and a Bitbucket API token with PR write access.
17
+ - name: Onboard a Client Area brand (web-client-area)
18
+ hosts: localhost
19
+ connection: local
20
+ gather_facts: false
21
+
22
+ vars_prompt:
23
+ - name: brand_name
24
+ prompt: "Brand display name — used in the PR title (e.g. Zenith Horizon Group)"
25
+ private: false
26
+ - name: brand_assets_folder
27
+ prompt: "Brand assets folder name — the src/assets/other/<folder> (e.g. zenithhorizongroup); leave blank to derive from the display name"
28
+ default: ""
29
+ private: false
30
+ - name: jira_key
31
+ prompt: "Jira key (e.g. ATLP-47067)"
32
+ private: false
33
+ - name: dest_branches
34
+ prompt: "Destination branches, comma-separated (e.g. develop,master-26.9)"
35
+ private: false
36
+ - name: bitbucket_token
37
+ prompt: "Bitbucket API token"
38
+ private: true
39
+
40
+ roles:
41
+ - onboard_ca
@@ -1,24 +1,24 @@
1
- ---
2
- # Pinned published antelope-cli version that provides the `onboarding-ca` command.
3
- antelope_cli_version: "1.2.0"
4
-
5
- # Where web-client-area is cloned on the control node.
6
- work_dir: "/tmp/onboard-ca/web-client-area"
7
-
8
- # Brand assets folder name (used for ENV_branding.brand_assets_folder and the src/assets/other/<folder>).
9
- # Empty => derived from brand_name (lowercased, spaces removed), matching antelope-cli's
10
- # connectedBrandName so the folder name is identical across repos.
11
- brand_assets_folder: ""
12
-
13
- # Reviewers for the PR. Empty => auto-fetched from the repo's Bitbucket "Default reviewers"
14
- # config (the authenticating account is excluded automatically). Override with an explicit
15
- # list, e.g. [{ account_id: "..." }] or [{ uuid: "{...}" }], to bypass the lookup.
16
- reviewers: []
17
-
18
- # Identity used for the commit (control-node git may have no global config).
19
- git_user_name: "Antelope Onboarding Bot"
20
- git_user_email: "devops@antelopesystem.com"
21
-
22
- # Bitbucket API token (Bearer) for the reviewer lookup + PR creation.
23
- # Provide via --extra-vars or Ansible Vault; never commit a real value.
24
- bitbucket_token: ""
1
+ ---
2
+ # Pinned published antelope-cli version that provides the `onboarding-ca` command.
3
+ antelope_cli_version: "1.2.0"
4
+
5
+ # Where web-client-area is cloned on the control node.
6
+ work_dir: "/tmp/onboard-ca/web-client-area"
7
+
8
+ # Brand assets folder name (used for ENV_branding.brand_assets_folder and the src/assets/other/<folder>).
9
+ # Empty => derived from brand_name (lowercased, spaces removed), matching antelope-cli's
10
+ # connectedBrandName so the folder name is identical across repos.
11
+ brand_assets_folder: ""
12
+
13
+ # Reviewers for the PR. Empty => auto-fetched from the repo's Bitbucket "Default reviewers"
14
+ # config (the authenticating account is excluded automatically). Override with an explicit
15
+ # list, e.g. [{ account_id: "..." }] or [{ uuid: "{...}" }], to bypass the lookup.
16
+ reviewers: []
17
+
18
+ # Identity used for the commit (control-node git may have no global config).
19
+ git_user_name: "Antelope Onboarding Bot"
20
+ git_user_email: "devops@antelopesystem.com"
21
+
22
+ # Bitbucket API token (Bearer) for the reviewer lookup + PR creation.
23
+ # Provide via --extra-vars or Ansible Vault; never commit a real value.
24
+ bitbucket_token: ""
@@ -1,10 +1,10 @@
1
- ---
2
- galaxy_info:
3
- role_name: onboard_ca
4
- author: Antelope Systems
5
- description: >-
6
- Onboard a Client Area brand: create the brand assets in web-client-area
7
- (via antelope-cli onboarding-ca) and open the pull request(s).
8
- license: ISC
9
- min_ansible_version: "2.12"
10
- dependencies: []
1
+ ---
2
+ galaxy_info:
3
+ role_name: onboard_ca
4
+ author: Antelope Systems
5
+ description: >-
6
+ Onboard a Client Area brand: create the brand assets in web-client-area
7
+ (via antelope-cli onboarding-ca) and open the pull request(s).
8
+ license: ISC
9
+ min_ansible_version: "2.12"
10
+ dependencies: []
@@ -1,76 +1,76 @@
1
- ---
2
- - name: Validate required inputs
3
- ansible.builtin.assert:
4
- that:
5
- - brand_name is defined and (brand_name | length) > 0
6
- - jira_key is defined and (jira_key | length) > 0
7
- - dest_branches is defined and (dest_branches | length) > 0
8
- - bitbucket_token is defined and (bitbucket_token | length) > 0
9
- fail_msg: "brand_name, jira_key, dest_branches and bitbucket_token are all required."
10
-
11
- - name: Compute effective brand assets folder
12
- ansible.builtin.set_fact:
13
- brand_assets_folder: >-
14
- {{ brand_assets_folder
15
- if (brand_assets_folder | default('') | length) > 0
16
- else (brand_name | lower | regex_replace(' ', '')) }}
17
-
18
- - name: Normalize destination branch list
19
- ansible.builtin.set_fact:
20
- dest_branch_list: "{{ dest_branches.split(',') | map('trim') | reject('equalto', '') | list }}"
21
-
22
- # --- Reviewers: pull from the repo's Bitbucket default-reviewers config -------------
23
- - name: Resolve reviewers from repo default-reviewers config
24
- when: (reviewers | length) == 0
25
- block:
26
- - name: Identify the authenticating Bitbucket account (PR author)
27
- ansible.builtin.uri:
28
- url: "{{ api_base }}/user"
29
- headers:
30
- Authorization: "Bearer {{ bitbucket_token }}"
31
- return_content: true
32
- register: bb_user
33
-
34
- - name: Fetch the repository default reviewers
35
- ansible.builtin.uri:
36
- url: "{{ api_base }}/repositories/{{ workspace }}/{{ repo_slug }}/default-reviewers?pagelen=100"
37
- headers:
38
- Authorization: "Bearer {{ bitbucket_token }}"
39
- return_content: true
40
- register: bb_default_reviewers
41
-
42
- # Bitbucket rejects a PR whose author is also a reviewer, so drop the authenticating account.
43
- # The REST API does not auto-apply default reviewers, so we pass them explicitly.
44
- # Bitbucket's PR-create reviewers array is keyed by uuid; exclude the author by account_id.
45
- - name: Build reviewers list (excluding the PR author)
46
- ansible.builtin.set_fact:
47
- reviewers: "{{ reviewers + [{'uuid': item.uuid}] }}"
48
- loop: "{{ bb_default_reviewers.json['values'] }}"
49
- when: item.account_id != bb_user.json.account_id
50
- loop_control:
51
- label: "{{ item.display_name | default(item.uuid) }}"
52
-
53
- - name: Ensure clone parent directory exists
54
- ansible.builtin.file:
55
- path: "{{ work_dir | dirname }}"
56
- state: directory
57
- mode: "0755"
58
-
59
- - name: Clone / refresh web-client-area over SSH
60
- ansible.builtin.git:
61
- repo: "{{ repo_ssh_url }}"
62
- dest: "{{ work_dir }}"
63
- version: "{{ dest_branch_list[0] }}"
64
- update: true
65
- force: true
66
- accept_hostkey: true
67
-
68
- - name: Onboard the brand on each destination branch
69
- ansible.builtin.include_tasks: per_branch.yml
70
- loop: "{{ dest_branch_list }}"
71
- loop_control:
72
- loop_var: dest_branch
73
-
74
- - name: Summary of pull requests
75
- ansible.builtin.debug:
76
- msg: "{{ pr_results | default([]) }}"
1
+ ---
2
+ - name: Validate required inputs
3
+ ansible.builtin.assert:
4
+ that:
5
+ - brand_name is defined and (brand_name | length) > 0
6
+ - jira_key is defined and (jira_key | length) > 0
7
+ - dest_branches is defined and (dest_branches | length) > 0
8
+ - bitbucket_token is defined and (bitbucket_token | length) > 0
9
+ fail_msg: "brand_name, jira_key, dest_branches and bitbucket_token are all required."
10
+
11
+ - name: Compute effective brand assets folder
12
+ ansible.builtin.set_fact:
13
+ brand_assets_folder: >-
14
+ {{ brand_assets_folder
15
+ if (brand_assets_folder | default('') | length) > 0
16
+ else (brand_name | lower | regex_replace(' ', '')) }}
17
+
18
+ - name: Normalize destination branch list
19
+ ansible.builtin.set_fact:
20
+ dest_branch_list: "{{ dest_branches.split(',') | map('trim') | reject('equalto', '') | list }}"
21
+
22
+ # --- Reviewers: pull from the repo's Bitbucket default-reviewers config -------------
23
+ - name: Resolve reviewers from repo default-reviewers config
24
+ when: (reviewers | length) == 0
25
+ block:
26
+ - name: Identify the authenticating Bitbucket account (PR author)
27
+ ansible.builtin.uri:
28
+ url: "{{ api_base }}/user"
29
+ headers:
30
+ Authorization: "Bearer {{ bitbucket_token }}"
31
+ return_content: true
32
+ register: bb_user
33
+
34
+ - name: Fetch the repository default reviewers
35
+ ansible.builtin.uri:
36
+ url: "{{ api_base }}/repositories/{{ workspace }}/{{ repo_slug }}/default-reviewers?pagelen=100"
37
+ headers:
38
+ Authorization: "Bearer {{ bitbucket_token }}"
39
+ return_content: true
40
+ register: bb_default_reviewers
41
+
42
+ # Bitbucket rejects a PR whose author is also a reviewer, so drop the authenticating account.
43
+ # The REST API does not auto-apply default reviewers, so we pass them explicitly.
44
+ # Bitbucket's PR-create reviewers array is keyed by uuid; exclude the author by account_id.
45
+ - name: Build reviewers list (excluding the PR author)
46
+ ansible.builtin.set_fact:
47
+ reviewers: "{{ reviewers + [{'uuid': item.uuid}] }}"
48
+ loop: "{{ bb_default_reviewers.json['values'] }}"
49
+ when: item.account_id != bb_user.json.account_id
50
+ loop_control:
51
+ label: "{{ item.display_name | default(item.uuid) }}"
52
+
53
+ - name: Ensure clone parent directory exists
54
+ ansible.builtin.file:
55
+ path: "{{ work_dir | dirname }}"
56
+ state: directory
57
+ mode: "0755"
58
+
59
+ - name: Clone / refresh web-client-area over SSH
60
+ ansible.builtin.git:
61
+ repo: "{{ repo_ssh_url }}"
62
+ dest: "{{ work_dir }}"
63
+ version: "{{ dest_branch_list[0] }}"
64
+ update: true
65
+ force: true
66
+ accept_hostkey: true
67
+
68
+ - name: Onboard the brand on each destination branch
69
+ ansible.builtin.include_tasks: per_branch.yml
70
+ loop: "{{ dest_branch_list }}"
71
+ loop_control:
72
+ loop_var: dest_branch
73
+
74
+ - name: Summary of pull requests
75
+ ansible.builtin.debug:
76
+ msg: "{{ pr_results | default([]) }}"