Skip to content

Commit 60be7c5

Browse files
committed
Updated notification variables.
1 parent 00b4356 commit 60be7c5

26 files changed

Lines changed: 239 additions & 41 deletions

File tree

.lagoon.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ tasks:
2727
command: |
2828
export VORTEX_NOTIFY_PROJECT=$LAGOON_PROJECT
2929
export VORTEX_NOTIFY_ENVIRONMENT_URL=$LAGOON_ROUTE
30+
export VORTEX_NOTIFY_BRANCH="${LAGOON_PR_HEAD_BRANCH:-$LAGOON_GIT_BRANCH}"
31+
export VORTEX_NOTIFY_SHA="${LAGOON_GIT_SHA}"
32+
export VORTEX_NOTIFY_PR_NUMBER="${LAGOON_PR_NUMBER:-}"
3033
export VORTEX_NOTIFY_LABEL="$LAGOON_GIT_BRANCH"
3134
[ -n "$LAGOON_PR_NUMBER" ] && export VORTEX_NOTIFY_LABEL="PR-${LAGOON_PR_NUMBER}"
3235
export VORTEX_NOTIFY_EVENT=pre_deployment
@@ -92,6 +95,9 @@ tasks:
9295
command: |
9396
export VORTEX_NOTIFY_PROJECT=$LAGOON_PROJECT
9497
export VORTEX_NOTIFY_ENVIRONMENT_URL=$LAGOON_ROUTE
98+
export VORTEX_NOTIFY_BRANCH="${LAGOON_PR_HEAD_BRANCH:-$LAGOON_GIT_BRANCH}"
99+
export VORTEX_NOTIFY_SHA="${LAGOON_GIT_SHA}"
100+
export VORTEX_NOTIFY_PR_NUMBER="${LAGOON_PR_NUMBER:-}"
95101
export VORTEX_NOTIFY_LABEL="$LAGOON_GIT_BRANCH"
96102
[ -n "$LAGOON_PR_NUMBER" ] && export VORTEX_NOTIFY_LABEL="PR-${LAGOON_PR_NUMBER}"
97103
export VORTEX_NOTIFY_EVENT=post_deployment

.vortex/docs/content/workflows/notifications.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,31 @@ channel-specific settings.
3636
| `VORTEX_NOTIFY_PROJECT` | No | `VORTEX_PROJECT` | `.env` | Notification project name |
3737
| `VORTEX_NOTIFY_SKIP` | No | | Hosting | Notification skip flag (set to `1` to skip notifications) |
3838

39+
## Deployment context variables
40+
41+
These variables provide deployment context information used by notification
42+
channels. They must be set by the hosting environment (e.g., Lagoon, Acquia)
43+
before calling the notification script.
44+
45+
| Variable | Required | Description |
46+
|---------------------------|----------|-----------------------------------------------------------------|
47+
| `VORTEX_NOTIFY_BRANCH` | **Yes** | Git branch name (used for GitHub API and JIRA issue extraction) |
48+
| `VORTEX_NOTIFY_SHA` | **Yes** | Git commit SHA (used for New Relic revision tracking) |
49+
| `VORTEX_NOTIFY_PR_NUMBER` | No | Pull request number (empty for branch deployments) |
50+
| `VORTEX_NOTIFY_LABEL` | **Yes** | Human-readable deployment label for display |
51+
52+
### Branch vs PR deployment examples
53+
54+
The following table shows how these variables differ between branch and PR deployments:
55+
56+
| Variable | Branch deployment | PR deployment |
57+
|----------------------------|-----------------------------|-----------------------------------|
58+
| `VORTEX_NOTIFY_BRANCH` | `main` | `feature/PROJ-123-add-feature` |
59+
| `VORTEX_NOTIFY_SHA` | `abc123def456` | `def789abc012` |
60+
| `VORTEX_NOTIFY_PR_NUMBER` | *(empty)* | `123` |
61+
| `VORTEX_NOTIFY_LABEL` | `main` | `PR-123` |
62+
63+
3964
## Message templates and tokens
4065

4166
Most notification channels support customizable message templates using replacement tokens:

.vortex/docs/content/workflows/variables.mdx

Lines changed: 10 additions & 5 deletions
Large diffs are not rendered by default.

.vortex/installer/tests/Fixtures/handler_process/hosting_acquia/hooks/library/notify-deployment.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set -e
99
site="${1}"
1010
target_env="${2}"
1111
branch="${3}"
12+
ref="${4}"
1213

1314
# Custom domain name for the environment, including subdomain.
1415
# Examples: "dev.example.com", "test.example.com", "www.example.com"
@@ -25,6 +26,9 @@ if [ -n "${VORTEX_NOTIFY_ENVIRONMENT_DOMAIN}" ]; then
2526
fi
2627

2728
export VORTEX_NOTIFY_PROJECT="${site}"
29+
export VORTEX_NOTIFY_BRANCH="${branch}"
30+
export VORTEX_NOTIFY_SHA="${ref}"
31+
export VORTEX_NOTIFY_PR_NUMBER=""
2832
export VORTEX_NOTIFY_LABEL="${branch}"
2933
export VORTEX_NOTIFY_ENVIRONMENT_URL="${url}"
3034

.vortex/installer/tests/Fixtures/handler_process/hosting_lagoon/.lagoon.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ tasks:
2626
command: |
2727
export VORTEX_NOTIFY_PROJECT=$LAGOON_PROJECT
2828
export VORTEX_NOTIFY_ENVIRONMENT_URL=$LAGOON_ROUTE
29+
export VORTEX_NOTIFY_BRANCH="${LAGOON_PR_HEAD_BRANCH:-$LAGOON_GIT_BRANCH}"
30+
export VORTEX_NOTIFY_SHA="${LAGOON_GIT_SHA}"
31+
export VORTEX_NOTIFY_PR_NUMBER="${LAGOON_PR_NUMBER:-}"
2932
export VORTEX_NOTIFY_LABEL="$LAGOON_GIT_BRANCH"
3033
[ -n "$LAGOON_PR_NUMBER" ] && export VORTEX_NOTIFY_LABEL="PR-${LAGOON_PR_NUMBER}"
3134
export VORTEX_NOTIFY_EVENT=pre_deployment
@@ -77,6 +80,9 @@ tasks:
7780
command: |
7881
export VORTEX_NOTIFY_PROJECT=$LAGOON_PROJECT
7982
export VORTEX_NOTIFY_ENVIRONMENT_URL=$LAGOON_ROUTE
83+
export VORTEX_NOTIFY_BRANCH="${LAGOON_PR_HEAD_BRANCH:-$LAGOON_GIT_BRANCH}"
84+
export VORTEX_NOTIFY_SHA="${LAGOON_GIT_SHA}"
85+
export VORTEX_NOTIFY_PR_NUMBER="${LAGOON_PR_NUMBER:-}"
8086
export VORTEX_NOTIFY_LABEL="$LAGOON_GIT_BRANCH"
8187
[ -n "$LAGOON_PR_NUMBER" ] && export VORTEX_NOTIFY_LABEL="PR-${LAGOON_PR_NUMBER}"
8288
export VORTEX_NOTIFY_EVENT=post_deployment

.vortex/installer/tests/Fixtures/handler_process/hosting_project_name___acquia/hooks/library/notify-deployment.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set -e
99
site="${1}"
1010
target_env="${2}"
1111
branch="${3}"
12+
ref="${4}"
1213

1314
# Custom domain name for the environment, including subdomain.
1415
# Examples: "dev.example.com", "test.example.com", "www.example.com"
@@ -25,6 +26,9 @@ if [ -n "${VORTEX_NOTIFY_ENVIRONMENT_DOMAIN}" ]; then
2526
fi
2627

2728
export VORTEX_NOTIFY_PROJECT="${site}"
29+
export VORTEX_NOTIFY_BRANCH="${branch}"
30+
export VORTEX_NOTIFY_SHA="${ref}"
31+
export VORTEX_NOTIFY_PR_NUMBER=""
2832
export VORTEX_NOTIFY_LABEL="${branch}"
2933
export VORTEX_NOTIFY_ENVIRONMENT_URL="${url}"
3034

.vortex/installer/tests/Fixtures/handler_process/hosting_project_name___lagoon/.lagoon.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ tasks:
2626
command: |
2727
export VORTEX_NOTIFY_PROJECT=$LAGOON_PROJECT
2828
export VORTEX_NOTIFY_ENVIRONMENT_URL=$LAGOON_ROUTE
29+
export VORTEX_NOTIFY_BRANCH="${LAGOON_PR_HEAD_BRANCH:-$LAGOON_GIT_BRANCH}"
30+
export VORTEX_NOTIFY_SHA="${LAGOON_GIT_SHA}"
31+
export VORTEX_NOTIFY_PR_NUMBER="${LAGOON_PR_NUMBER:-}"
2932
export VORTEX_NOTIFY_LABEL="$LAGOON_GIT_BRANCH"
3033
[ -n "$LAGOON_PR_NUMBER" ] && export VORTEX_NOTIFY_LABEL="PR-${LAGOON_PR_NUMBER}"
3134
export VORTEX_NOTIFY_EVENT=pre_deployment
@@ -77,6 +80,9 @@ tasks:
7780
command: |
7881
export VORTEX_NOTIFY_PROJECT=$LAGOON_PROJECT
7982
export VORTEX_NOTIFY_ENVIRONMENT_URL=$LAGOON_ROUTE
83+
export VORTEX_NOTIFY_BRANCH="${LAGOON_PR_HEAD_BRANCH:-$LAGOON_GIT_BRANCH}"
84+
export VORTEX_NOTIFY_SHA="${LAGOON_GIT_SHA}"
85+
export VORTEX_NOTIFY_PR_NUMBER="${LAGOON_PR_NUMBER:-}"
8086
export VORTEX_NOTIFY_LABEL="$LAGOON_GIT_BRANCH"
8187
[ -n "$LAGOON_PR_NUMBER" ] && export VORTEX_NOTIFY_LABEL="PR-${LAGOON_PR_NUMBER}"
8288
export VORTEX_NOTIFY_EVENT=post_deployment

.vortex/installer/tests/Fixtures/handler_process/provision_database_lagoon/.lagoon.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ tasks:
2626
command: |
2727
export VORTEX_NOTIFY_PROJECT=$LAGOON_PROJECT
2828
export VORTEX_NOTIFY_ENVIRONMENT_URL=$LAGOON_ROUTE
29+
export VORTEX_NOTIFY_BRANCH="${LAGOON_PR_HEAD_BRANCH:-$LAGOON_GIT_BRANCH}"
30+
export VORTEX_NOTIFY_SHA="${LAGOON_GIT_SHA}"
31+
export VORTEX_NOTIFY_PR_NUMBER="${LAGOON_PR_NUMBER:-}"
2932
export VORTEX_NOTIFY_LABEL="$LAGOON_GIT_BRANCH"
3033
[ -n "$LAGOON_PR_NUMBER" ] && export VORTEX_NOTIFY_LABEL="PR-${LAGOON_PR_NUMBER}"
3134
export VORTEX_NOTIFY_EVENT=pre_deployment
@@ -77,6 +80,9 @@ tasks:
7780
command: |
7881
export VORTEX_NOTIFY_PROJECT=$LAGOON_PROJECT
7982
export VORTEX_NOTIFY_ENVIRONMENT_URL=$LAGOON_ROUTE
83+
export VORTEX_NOTIFY_BRANCH="${LAGOON_PR_HEAD_BRANCH:-$LAGOON_GIT_BRANCH}"
84+
export VORTEX_NOTIFY_SHA="${LAGOON_GIT_SHA}"
85+
export VORTEX_NOTIFY_PR_NUMBER="${LAGOON_PR_NUMBER:-}"
8086
export VORTEX_NOTIFY_LABEL="$LAGOON_GIT_BRANCH"
8187
[ -n "$LAGOON_PR_NUMBER" ] && export VORTEX_NOTIFY_LABEL="PR-${LAGOON_PR_NUMBER}"
8288
export VORTEX_NOTIFY_EVENT=post_deployment

.vortex/tests/bats/unit/notify-email.bats

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ load ../_helper.bash
1313
export VORTEX_NOTIFY_PROJECT="testproject"
1414
export DRUPAL_SITE_EMAIL="testproject@example.com"
1515
export VORTEX_NOTIFY_EMAIL_RECIPIENTS="john@example.com|John Doe, jane@example.com|Jane Doe, jim@example.com"
16+
export VORTEX_NOTIFY_BRANCH="develop"
17+
export VORTEX_NOTIFY_SHA="abc123def456"
1618
export VORTEX_NOTIFY_LABEL="develop"
1719
export VORTEX_NOTIFY_ENVIRONMENT_URL="https://develop.testproject.com"
1820
run ./scripts/vortex/notify.sh
@@ -40,7 +42,10 @@ load ../_helper.bash
4042
export VORTEX_NOTIFY_PROJECT="testproject"
4143
export DRUPAL_SITE_EMAIL="testproject@example.com"
4244
export VORTEX_NOTIFY_EMAIL_RECIPIENTS="john@example.com|John Doe, jane@example.com|Jane Doe"
43-
export VORTEX_NOTIFY_LABEL="develop"
45+
export VORTEX_NOTIFY_BRANCH="feature/my-pr-branch"
46+
export VORTEX_NOTIFY_SHA="abc123def456"
47+
export VORTEX_NOTIFY_PR_NUMBER="123"
48+
export VORTEX_NOTIFY_LABEL="PR-123"
4449
export VORTEX_NOTIFY_ENVIRONMENT_URL="https://develop.testproject.com"
4550
run ./scripts/vortex/notify.sh
4651
assert_success
@@ -51,8 +56,8 @@ load ../_helper.bash
5156
assert_output_contains "Notification email(s) sent to: john@example.com, jane@example.com"
5257
assert_output_contains "Finished email notification."
5358

54-
assert_output_contains 'testproject deployment notification of develop'
55-
assert_output_contains 'Site testproject develop has been deployed'
59+
assert_output_contains 'testproject deployment notification of PR-123'
60+
assert_output_contains 'Site testproject PR-123 has been deployed'
5661
assert_output_contains "and is available at https://develop.testproject.com."
5762

5863
assert_output_contains "Finished dispatching notifications."
@@ -68,6 +73,8 @@ load ../_helper.bash
6873
export VORTEX_NOTIFY_PROJECT="testproject"
6974
export DRUPAL_SITE_EMAIL="testproject@example.com"
7075
export VORTEX_NOTIFY_EMAIL_RECIPIENTS="john@example.com"
76+
export VORTEX_NOTIFY_BRANCH="develop"
77+
export VORTEX_NOTIFY_SHA="abc123def456"
7178
export VORTEX_NOTIFY_LABEL="develop"
7279
export VORTEX_NOTIFY_ENVIRONMENT_URL="https://develop.testproject.com"
7380
run ./scripts/vortex/notify.sh
@@ -90,6 +97,8 @@ load ../_helper.bash
9097
export VORTEX_NOTIFY_PROJECT="test'); file_put_contents('/tmp/injected_email_test', 'HACKED'); //"
9198
export DRUPAL_SITE_EMAIL="testproject@example.com"
9299
export VORTEX_NOTIFY_EMAIL_RECIPIENTS="john@example.com"
100+
export VORTEX_NOTIFY_BRANCH="develop"
101+
export VORTEX_NOTIFY_SHA="abc123def456"
93102
export VORTEX_NOTIFY_LABEL="develop"
94103
export VORTEX_NOTIFY_ENVIRONMENT_URL="https://example.com"
95104

.vortex/tests/bats/unit/notify-github.bats

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ load ../_helper.bash
2626
export VORTEX_NOTIFY_EVENT="pre_deployment"
2727
export VORTEX_NOTIFY_GITHUB_TOKEN="token12345"
2828
export VORTEX_NOTIFY_GITHUB_REPOSITORY="myorg/myrepo"
29+
export VORTEX_NOTIFY_BRANCH="existingbranch"
30+
export VORTEX_NOTIFY_SHA="abc123def456"
2931
export VORTEX_NOTIFY_LABEL="existingbranch"
3032
export VORTEX_NOTIFY_ENVIRONMENT_URL="https://develop.testproject.com"
3133
run ./scripts/vortex/notify.sh
@@ -44,7 +46,7 @@ load ../_helper.bash
4446
declare -a STEPS=(
4547
"Started dispatching notifications."
4648
"Started GitHub notification for pre_deployment event."
47-
"@curl -X POST -H Authorization: token token12345 -H Accept: application/vnd.github.v3+json -s https://api.github.com/repos/myorg/myrepo/deployments -d {\"ref\":\"existingbranch\", \"environment\": \"PR\", \"auto_merge\": false, \"required_contexts\": []} # {\"id\": \"${app_id}\", \"othervar\": \"54321\"}"
49+
"@curl -X POST -H Authorization: token token12345 -H Accept: application/vnd.github.v3+json -s https://api.github.com/repos/myorg/myrepo/deployments -d {\"ref\":\"feature/my-pr-branch\", \"environment\": \"PR\", \"auto_merge\": false, \"required_contexts\": []} # {\"id\": \"${app_id}\", \"othervar\": \"54321\"}"
4850
"Marked deployment as started."
4951
"Finished GitHub notification for pre_deployment event."
5052
"Finished dispatching notifications."
@@ -56,7 +58,10 @@ load ../_helper.bash
5658
export VORTEX_NOTIFY_EVENT="pre_deployment"
5759
export VORTEX_NOTIFY_GITHUB_TOKEN="token12345"
5860
export VORTEX_NOTIFY_GITHUB_REPOSITORY="myorg/myrepo"
59-
export VORTEX_NOTIFY_LABEL="existingbranch"
61+
export VORTEX_NOTIFY_BRANCH="feature/my-pr-branch"
62+
export VORTEX_NOTIFY_SHA="abc123def456"
63+
export VORTEX_NOTIFY_PR_NUMBER="123"
64+
export VORTEX_NOTIFY_LABEL="PR-123"
6065
export VORTEX_NOTIFY_ENVIRONMENT_URL="https://develop.testproject.com"
6166
run ./scripts/vortex/notify.sh
6267
assert_success
@@ -86,6 +91,8 @@ load ../_helper.bash
8691
export VORTEX_NOTIFY_EVENT="pre_deployment"
8792
export VORTEX_NOTIFY_GITHUB_TOKEN="token12345"
8893
export VORTEX_NOTIFY_GITHUB_REPOSITORY="myorg/myrepo"
94+
export VORTEX_NOTIFY_BRANCH="existingbranch"
95+
export VORTEX_NOTIFY_SHA="abc123def456"
8996
export VORTEX_NOTIFY_LABEL="existingbranch"
9097
export VORTEX_NOTIFY_ENVIRONMENT_URL="https://develop.testproject.com"
9198
run ./scripts/vortex/notify.sh
@@ -114,6 +121,8 @@ load ../_helper.bash
114121
export VORTEX_NOTIFY_EVENT="pre_deployment"
115122
export VORTEX_NOTIFY_GITHUB_TOKEN="token12345"
116123
export VORTEX_NOTIFY_GITHUB_REPOSITORY="myorg/myrepo"
124+
export VORTEX_NOTIFY_BRANCH="nonexistingbranch"
125+
export VORTEX_NOTIFY_SHA="abc123def456"
117126
export VORTEX_NOTIFY_LABEL="nonexistingbranch"
118127
export VORTEX_NOTIFY_ENVIRONMENT_URL="https://develop.testproject.com"
119128
run ./scripts/vortex/notify.sh
@@ -145,6 +154,8 @@ load ../_helper.bash
145154
export VORTEX_NOTIFY_EVENT="post_deployment"
146155
export VORTEX_NOTIFY_GITHUB_TOKEN="token12345"
147156
export VORTEX_NOTIFY_GITHUB_REPOSITORY="myorg/myrepo"
157+
export VORTEX_NOTIFY_BRANCH="existingbranch"
158+
export VORTEX_NOTIFY_SHA="abc123def456"
148159
export VORTEX_NOTIFY_LABEL="existingbranch"
149160
export VORTEX_NOTIFY_ENVIRONMENT_URL="https://develop.testproject.com"
150161
run ./scripts/vortex/notify.sh
@@ -176,6 +187,8 @@ load ../_helper.bash
176187
export VORTEX_NOTIFY_EVENT="post_deployment"
177188
export VORTEX_NOTIFY_GITHUB_TOKEN="token12345"
178189
export VORTEX_NOTIFY_GITHUB_REPOSITORY="myorg/myrepo"
190+
export VORTEX_NOTIFY_BRANCH="existingbranch"
191+
export VORTEX_NOTIFY_SHA="abc123def456"
179192
export VORTEX_NOTIFY_LABEL="existingbranch"
180193
export VORTEX_NOTIFY_ENVIRONMENT_URL="https://develop.testproject.com"
181194
run ./scripts/vortex/notify.sh
@@ -205,6 +218,8 @@ load ../_helper.bash
205218
export VORTEX_NOTIFY_EVENT="post_deployment"
206219
export VORTEX_NOTIFY_GITHUB_TOKEN="token12345"
207220
export VORTEX_NOTIFY_GITHUB_REPOSITORY="myorg/myrepo"
221+
export VORTEX_NOTIFY_BRANCH="nonexistingbranch"
222+
export VORTEX_NOTIFY_SHA="abc123def456"
208223
export VORTEX_NOTIFY_LABEL="nonexistingbranch"
209224
export VORTEX_NOTIFY_ENVIRONMENT_URL="https://develop.testproject.com"
210225
run ./scripts/vortex/notify.sh
@@ -235,6 +250,8 @@ load ../_helper.bash
235250
export VORTEX_NOTIFY_EVENT="post_deployment"
236251
export VORTEX_NOTIFY_GITHUB_TOKEN="token12345"
237252
export VORTEX_NOTIFY_GITHUB_REPOSITORY="myorg/myrepo"
253+
export VORTEX_NOTIFY_BRANCH="existingbranch"
254+
export VORTEX_NOTIFY_SHA="abc123def456"
238255
export VORTEX_NOTIFY_LABEL="existingbranch"
239256
export VORTEX_NOTIFY_ENVIRONMENT_URL="https://develop.testproject.com"
240257
run ./scripts/vortex/notify.sh

0 commit comments

Comments
 (0)