Skip to content

Commit 33fdfc5

Browse files
committed
[#1428] Updated deployment bypass mechanism to use list-based variables.
- Replaced individual `VORTEX_DEPLOY_SKIP_PR_<NUMBER>` and `VORTEX_DEPLOY_SKIP_BRANCH_<SAFE_BRANCH>` variables with comma-separated list variables - Added `VORTEX_DEPLOY_SKIP_PRS` for PR numbers (single or comma-separated) - Added `VORTEX_DEPLOY_SKIP_BRANCHES` for branch names (single or comma-separated) - Updated `scripts/vortex/deploy.sh` with new list-based skip logic - Updated PHPUnit tests to cover new skip scenarios - Updated documentation for deployment workflows and variables - Updated GitHub Actions workflow to include new environment variables - Updated CI variables configuration - Updated installer baseline fixtures This is a breaking change. Projects using the old mechanism will need to migrate from: VORTEX_DEPLOY_SKIP_PR_123: "1" VORTEX_DEPLOY_SKIP_BRANCH_FEATURE_TEST: "1" To: VORTEX_DEPLOY_ALLOW_SKIP: "1" VORTEX_DEPLOY_SKIP_PRS: "123" VORTEX_DEPLOY_SKIP_BRANCHES: "feature/test"
1 parent dafe633 commit 33fdfc5

File tree

8 files changed

+163
-58
lines changed

8 files changed

+163
-58
lines changed

.github/workflows/build-test-deploy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,5 +475,8 @@ jobs:
475475
VORTEX_DEPLOY_ARTIFACT_GIT_USER_NAME: ${{ vars.VORTEX_DEPLOY_ARTIFACT_GIT_USER_NAME }}
476476
VORTEX_DEPLOY_WEBHOOK_URL: ${{ vars.VORTEX_DEPLOY_WEBHOOK_URL }}
477477
VORTEX_DEPLOY_SKIP: ${{ vars.VORTEX_DEPLOY_SKIP }}
478+
VORTEX_DEPLOY_ALLOW_SKIP: ${{ vars.VORTEX_DEPLOY_ALLOW_SKIP }}
479+
VORTEX_DEPLOY_SKIP_PRS: ${{ vars.VORTEX_DEPLOY_SKIP_PRS }}
480+
VORTEX_DEPLOY_SKIP_BRANCHES: ${{ vars.VORTEX_DEPLOY_SKIP_BRANCHES }}
478481
timeout-minutes: 30
479482
#;> DEPLOYMENT

.vortex/docs/.utils/variables/extra/ci.variables.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
# Skip all deployments.
77
VORTEX_DEPLOY_SKIP=
88

9+
# Flag to allow skipping of a deployment using additional flags.
10+
VORTEX_DEPLOY_ALLOW_SKIP=
11+
12+
# Pull request numbers to skip deployment for (single value or comma-separated list).
13+
VORTEX_DEPLOY_SKIP_PRS=
14+
15+
# Branch names to skip deployment for (single value or comma-separated list).
16+
VORTEX_DEPLOY_SKIP_BRANCHES=
17+
918
# Proceed with container image deployment after it was exported.
1019
VORTEX_EXPORT_DB_CONTAINER_REGISTRY_DEPLOY_PROCEED=
1120

.vortex/docs/content/workflows/deployment.mdx

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,31 +75,45 @@ variable to `1`.
7575
This is especially useful in continuous integration pipelines where you may want to build and test
7676
without triggering a deployment.
7777

78-
### Skipping deployments for a specific Pull Requests or branches
78+
### Skipping deployments for specific Pull Requests or branches
7979

80-
To skip a specific Pull Request or branch using the `$VORTEX_DEPLOY_SKIP`
81-
variable, you would define additional environment variables with a specific
82-
naming convention in your continuous integration pipeline configuration.
80+
To skip specific Pull Requests or branches, set `$VORTEX_DEPLOY_ALLOW_SKIP` to `1`
81+
and provide lists in the following variables:
8382

84-
Here's an example of how this can be done:
83+
#### Skipping specific Pull Requests
8584

86-
#### Skipping a specific Pull Request
85+
Set `$VORTEX_DEPLOY_SKIP_PRS` to a single PR number or comma-separated list:
8786

88-
Suppose you want to skip the deployment for Pull Request number 42. You would
89-
set the following environment variable:
87+
```bash
88+
# Skip a single PR
89+
VORTEX_DEPLOY_ALLOW_SKIP=1
90+
VORTEX_DEPLOY_SKIP_PRS=42
9091

91-
```bash
92-
VORTEX_DEPLOY_SKIP_PR_42=1
93-
```
92+
# Skip multiple PRs
93+
VORTEX_DEPLOY_ALLOW_SKIP=1
94+
VORTEX_DEPLOY_SKIP_PRS=42,123,456
95+
```
9496

95-
#### Skipping a specific branch
97+
#### Skipping specific branches
9698

97-
Suppose you want to skip the deployment for a branch named `feature-x`. You
98-
would first create a "safe" version of the branch name by replacing any
99-
special characters with underscores.
99+
Set `$VORTEX_DEPLOY_SKIP_BRANCHES` to a single branch name or comma-separated list:
100100

101-
Set the following environment variable:
101+
```bash
102+
# Skip a single branch
103+
VORTEX_DEPLOY_ALLOW_SKIP=1
104+
VORTEX_DEPLOY_SKIP_BRANCHES=feature/test
102105

103-
```bash
104-
VORTEX_DEPLOY_SKIP_BRANCH_FEATURE_X=1
105-
```
106+
# Skip multiple branches
107+
VORTEX_DEPLOY_ALLOW_SKIP=1
108+
VORTEX_DEPLOY_SKIP_BRANCHES=feature/test,hotfix/urgent,project/experimental
109+
```
110+
111+
#### Combined usage
112+
113+
You can use both variables together:
114+
115+
```bash
116+
VORTEX_DEPLOY_ALLOW_SKIP=1
117+
VORTEX_DEPLOY_SKIP_PRS=42,123
118+
VORTEX_DEPLOY_SKIP_BRANCHES=feature/test,hotfix/urgent
119+
```

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ Flag to allow skipping of a deployment using additional flags.
852852

853853
Default value: `UNDEFINED`
854854

855-
Defined or used in: `scripts/vortex/deploy.sh`
855+
Defined or used in: `CI config`, `scripts/vortex/deploy.sh`
856856

857857
### `VORTEX_DEPLOY_ARTIFACT_DST_BRANCH`
858858

@@ -1042,6 +1042,22 @@ Default value: `UNDEFINED`
10421042

10431043
Defined or used in: `CI config`
10441044

1045+
### `VORTEX_DEPLOY_SKIP_BRANCHES`
1046+
1047+
Branch names to skip deployment for (single value or comma-separated list).
1048+
1049+
Default value: `UNDEFINED`
1050+
1051+
Defined or used in: `CI config`, `scripts/vortex/deploy.sh`
1052+
1053+
### `VORTEX_DEPLOY_SKIP_PRS`
1054+
1055+
Pull request numbers to skip deployment for (single value or comma-separated list).
1056+
1057+
Default value: `UNDEFINED`
1058+
1059+
Defined or used in: `CI config`, `scripts/vortex/deploy.sh`
1060+
10451061
### `VORTEX_DEPLOY_SSH_FILE`
10461062

10471063
Default SSH file used if custom fingerprint is not provided.

.vortex/installer/tests/Fixtures/install/_baseline/.github/workflows/build-test-deploy.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,4 +438,7 @@ jobs:
438438
VORTEX_DEPLOY_ARTIFACT_GIT_USER_NAME: ${{ vars.VORTEX_DEPLOY_ARTIFACT_GIT_USER_NAME }}
439439
VORTEX_DEPLOY_WEBHOOK_URL: ${{ vars.VORTEX_DEPLOY_WEBHOOK_URL }}
440440
VORTEX_DEPLOY_SKIP: ${{ vars.VORTEX_DEPLOY_SKIP }}
441+
VORTEX_DEPLOY_ALLOW_SKIP: ${{ vars.VORTEX_DEPLOY_ALLOW_SKIP }}
442+
VORTEX_DEPLOY_SKIP_PRS: ${{ vars.VORTEX_DEPLOY_SKIP_PRS }}
443+
VORTEX_DEPLOY_SKIP_BRANCHES: ${{ vars.VORTEX_DEPLOY_SKIP_BRANCHES }}
441444
timeout-minutes: 30

.vortex/installer/tests/Fixtures/install/deploy_types_none_gha/.github/workflows/build-test-deploy.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@@ -369,73 +369,3 @@
1+
@@ -369,76 +369,3 @@
22
timeout-minutes: 120 # Cancel the action after 15 minutes, regardless of whether a connection has been established.
33
with:
44
detached: true
@@ -71,4 +71,7 @@
7171
- VORTEX_DEPLOY_ARTIFACT_GIT_USER_NAME: ${{ vars.VORTEX_DEPLOY_ARTIFACT_GIT_USER_NAME }}
7272
- VORTEX_DEPLOY_WEBHOOK_URL: ${{ vars.VORTEX_DEPLOY_WEBHOOK_URL }}
7373
- VORTEX_DEPLOY_SKIP: ${{ vars.VORTEX_DEPLOY_SKIP }}
74+
- VORTEX_DEPLOY_ALLOW_SKIP: ${{ vars.VORTEX_DEPLOY_ALLOW_SKIP }}
75+
- VORTEX_DEPLOY_SKIP_PRS: ${{ vars.VORTEX_DEPLOY_SKIP_PRS }}
76+
- VORTEX_DEPLOY_SKIP_BRANCHES: ${{ vars.VORTEX_DEPLOY_SKIP_BRANCHES }}
7477
- timeout-minutes: 30

.vortex/tests/phpunit/Functional/DeploymentTest.php

Lines changed: 76 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function testDeploymentSkipFlags(): void {
7575
'VORTEX_DEPLOY_WEBHOOK_RESPONSE_STATUS' => '200',
7676
]);
7777

78-
$this->logSubstep('Subtest 2: Run deployment with skip flag but no per-branch skip');
78+
$this->logSubstep('Subtest 2: Run deployment with ALLOW_SKIP but no skip lists');
7979
$this->cmd('ahoy deploy', [
8080
'* Found flag to skip a deployment.',
8181
'* Started WEBHOOK deployment.',
@@ -88,39 +88,99 @@ public function testDeploymentSkipFlags(): void {
8888
'VORTEX_DEPLOY_ALLOW_SKIP' => '1',
8989
]);
9090

91-
$this->logSubstep('Subtest 3: Run deployment with per-branch skip flag');
91+
$this->logSubstep('Subtest 3: Skip deployment for single PR');
9292
$this->cmd('ahoy deploy', [
9393
'* Found flag to skip a deployment.',
94-
'* Found skip variable VORTEX_DEPLOY_SKIP_BRANCH_FEATURE_TEST',
94+
'* Found PR 123 in skip list.',
9595
'* Skipping deployment webhook.',
9696
'! Started WEBHOOK deployment.',
97-
'! Finished WEBHOOK deployment.',
98-
], txt: 'Deployment should be skipped for feature/test branch', env: [
97+
], txt: 'Deployment should be skipped for single PR', env: [
9998
'VORTEX_DEPLOY_TYPES' => 'webhook',
10099
'VORTEX_DEPLOY_WEBHOOK_URL' => 'https://www.example.com',
101100
'VORTEX_DEPLOY_WEBHOOK_RESPONSE_STATUS' => '200',
102101
'VORTEX_DEPLOY_ALLOW_SKIP' => '1',
103-
'VORTEX_DEPLOY_BRANCH' => 'feature/test',
104-
'VORTEX_DEPLOY_SKIP_BRANCH_FEATURE_TEST' => '1',
102+
'VORTEX_DEPLOY_PR' => '123',
103+
'VORTEX_DEPLOY_SKIP_PRS' => '123',
105104
]);
106105

107-
$this->logSubstep('Subtest 4: Run deployment with per-PR skip flag');
106+
$this->logSubstep('Subtest 4: Skip deployment for PR in comma-separated list');
108107
$this->cmd('ahoy deploy', [
109108
'* Found flag to skip a deployment.',
110-
'* Found skip variable VORTEX_DEPLOY_SKIP_PR_123',
109+
'* Found PR 123 in skip list.',
111110
'* Skipping deployment webhook.',
112111
'! Started WEBHOOK deployment.',
113-
'! Finished WEBHOOK deployment.',
114-
], txt: 'Deployment should be skipped for PR 123', env: [
112+
], txt: 'Deployment should be skipped for PR 123 in list', env: [
115113
'VORTEX_DEPLOY_TYPES' => 'webhook',
116114
'VORTEX_DEPLOY_WEBHOOK_URL' => 'https://www.example.com',
117115
'VORTEX_DEPLOY_WEBHOOK_RESPONSE_STATUS' => '200',
118116
'VORTEX_DEPLOY_ALLOW_SKIP' => '1',
119117
'VORTEX_DEPLOY_PR' => '123',
120-
'VORTEX_DEPLOY_SKIP_PR_123' => '1',
118+
'VORTEX_DEPLOY_SKIP_PRS' => '123,456,789',
121119
]);
122120

123-
$this->logSubstep('Subtest 5: Run deployment without skip flag but with per-PR');
121+
$this->logSubstep('Subtest 5: Allow deployment for PR not in skip list');
122+
$this->cmd('ahoy deploy', [
123+
'* Found flag to skip a deployment.',
124+
'* Started WEBHOOK deployment.',
125+
'* Finished WEBHOOK deployment.',
126+
'! Found PR 999 in skip list.',
127+
'! Skipping deployment webhook.',
128+
], txt: 'Deployment should proceed for PR 999 not in skip list', env: [
129+
'VORTEX_DEPLOY_TYPES' => 'webhook',
130+
'VORTEX_DEPLOY_WEBHOOK_URL' => 'https://www.example.com',
131+
'VORTEX_DEPLOY_WEBHOOK_RESPONSE_STATUS' => '200',
132+
'VORTEX_DEPLOY_ALLOW_SKIP' => '1',
133+
'VORTEX_DEPLOY_PR' => '999',
134+
'VORTEX_DEPLOY_SKIP_PRS' => '123,456,789',
135+
]);
136+
137+
$this->logSubstep('Subtest 6: Skip deployment for single branch');
138+
$this->cmd('ahoy deploy', [
139+
'* Found flag to skip a deployment.',
140+
'* Found branch feature/test in skip list.',
141+
'* Skipping deployment webhook.',
142+
'! Started WEBHOOK deployment.',
143+
], txt: 'Deployment should be skipped for single branch', env: [
144+
'VORTEX_DEPLOY_TYPES' => 'webhook',
145+
'VORTEX_DEPLOY_WEBHOOK_URL' => 'https://www.example.com',
146+
'VORTEX_DEPLOY_WEBHOOK_RESPONSE_STATUS' => '200',
147+
'VORTEX_DEPLOY_ALLOW_SKIP' => '1',
148+
'VORTEX_DEPLOY_BRANCH' => 'feature/test',
149+
'VORTEX_DEPLOY_SKIP_BRANCHES' => 'feature/test',
150+
]);
151+
152+
$this->logSubstep('Subtest 7: Skip deployment for branch in comma-separated list');
153+
$this->cmd('ahoy deploy', [
154+
'* Found flag to skip a deployment.',
155+
'* Found branch feature/test in skip list.',
156+
'* Skipping deployment webhook.',
157+
'! Started WEBHOOK deployment.',
158+
], txt: 'Deployment should be skipped for branch in list', env: [
159+
'VORTEX_DEPLOY_TYPES' => 'webhook',
160+
'VORTEX_DEPLOY_WEBHOOK_URL' => 'https://www.example.com',
161+
'VORTEX_DEPLOY_WEBHOOK_RESPONSE_STATUS' => '200',
162+
'VORTEX_DEPLOY_ALLOW_SKIP' => '1',
163+
'VORTEX_DEPLOY_BRANCH' => 'feature/test',
164+
'VORTEX_DEPLOY_SKIP_BRANCHES' => 'feature/test,hotfix/urgent,project/experimental',
165+
]);
166+
167+
$this->logSubstep('Subtest 8: Allow deployment for branch not in skip list');
168+
$this->cmd('ahoy deploy', [
169+
'* Found flag to skip a deployment.',
170+
'* Started WEBHOOK deployment.',
171+
'* Finished WEBHOOK deployment.',
172+
'! Found branch develop in skip list.',
173+
'! Skipping deployment webhook.',
174+
], txt: 'Deployment should proceed for branch not in skip list', env: [
175+
'VORTEX_DEPLOY_TYPES' => 'webhook',
176+
'VORTEX_DEPLOY_WEBHOOK_URL' => 'https://www.example.com',
177+
'VORTEX_DEPLOY_WEBHOOK_RESPONSE_STATUS' => '200',
178+
'VORTEX_DEPLOY_ALLOW_SKIP' => '1',
179+
'VORTEX_DEPLOY_BRANCH' => 'develop',
180+
'VORTEX_DEPLOY_SKIP_BRANCHES' => 'feature/test,hotfix/urgent',
181+
]);
182+
183+
$this->logSubstep('Subtest 9: Run deployment without ALLOW_SKIP despite skip lists');
124184
$this->cmd('ahoy deploy', [
125185
'* Started WEBHOOK deployment.',
126186
'* Finished WEBHOOK deployment.',
@@ -131,7 +191,9 @@ public function testDeploymentSkipFlags(): void {
131191
'VORTEX_DEPLOY_WEBHOOK_URL' => 'https://www.example.com',
132192
'VORTEX_DEPLOY_WEBHOOK_RESPONSE_STATUS' => '200',
133193
'VORTEX_DEPLOY_PR' => '123',
134-
'VORTEX_DEPLOY_SKIP_PR_123' => '1',
194+
'VORTEX_DEPLOY_SKIP_PRS' => '123',
195+
'VORTEX_DEPLOY_BRANCH' => 'feature/test',
196+
'VORTEX_DEPLOY_SKIP_BRANCHES' => 'feature/test',
135197
]);
136198

137199
$this->logStepFinish();

scripts/vortex/deploy.sh

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,36 +72,31 @@ fi
7272
if [ "${VORTEX_DEPLOY_ALLOW_SKIP:-}" = "1" ]; then
7373
note "Found flag to skip a deployment."
7474

75-
if [ -n "${VORTEX_DEPLOY_PR}" ]; then
76-
# Allow skipping deployment by providing `$VORTEX_DEPLOY_SKIP_PR_<NUMBER>`
77-
# variable with value set to "1", where `<NUMBER>` is a PR number name with
78-
# spaces, hyphens and forward slashes replaced with underscores and then
79-
# capitalised.
75+
if [ -n "${VORTEX_DEPLOY_PR}" ] && [ -n "${VORTEX_DEPLOY_SKIP_PRS:-}" ]; then
76+
# Allow skipping deployment by providing `$VORTEX_DEPLOY_SKIP_PRS` variable
77+
# with PR numbers as a single value or comma-separated list.
8078
#
81-
# Example:
82-
# For PR named 'pr-123', the variable name is $VORTEX_DEPLOY_SKIP_PR_123
83-
pr_skip_var="VORTEX_DEPLOY_SKIP_PR_${VORTEX_DEPLOY_PR}"
84-
if [ -n "${!pr_skip_var}" ]; then
85-
note "Found skip variable ${pr_skip_var} for PR ${VORTEX_DEPLOY_PR}."
79+
# Examples:
80+
# VORTEX_DEPLOY_SKIP_PRS=123
81+
# VORTEX_DEPLOY_SKIP_PRS=123,456,789
82+
if echo ",${VORTEX_DEPLOY_SKIP_PRS}," | grep -q ",${VORTEX_DEPLOY_PR},"; then
83+
note "Found PR ${VORTEX_DEPLOY_PR} in skip list."
8684
note "Skipping deployment ${VORTEX_DEPLOY_TYPES}."
8785
exit 0
8886
fi
8987
fi
9088

91-
if [ -n "${VORTEX_DEPLOY_BRANCH:-}" ]; then
92-
# Allow skipping deployment by providing 'VORTEX_DEPLOY_SKIP_BRANCH_<SAFE_BRANCH>'
93-
# variable with value set to "1", where <SAFE_BRANCH> is a branch name with
94-
# spaces, hyphens and forward slashes replaced with underscores and then
95-
# capitalised.
89+
if [ -n "${VORTEX_DEPLOY_BRANCH:-}" ] && [ -n "${VORTEX_DEPLOY_SKIP_BRANCHES:-}" ]; then
90+
# Allow skipping deployment by providing `$VORTEX_DEPLOY_SKIP_BRANCHES`
91+
# variable with branch names as a single value or comma-separated list.
9692
#
97-
# Example:
98-
# For 'main' branch, the variable name is $VORTEX_DEPLOY_SKIP_BRANCH_MAIN
99-
# For 'feature/my complex feature-123 update' branch, the variable name
100-
# is $VORTEX_DEPLOY_SKIP_BRANCH_MY_COMPLEX_FEATURE_123_UPDATE
101-
safe_branch_name="$(echo "${VORTEX_DEPLOY_BRANCH}" | tr -d '\n' | tr '[:space:]' '_' | tr '-' '_' | tr '/' '_' | tr -cd '[:alnum:]_' | tr '[:lower:]' '[:upper:]')"
102-
branch_skip_var="VORTEX_DEPLOY_SKIP_BRANCH_${safe_branch_name}"
103-
if [ -n "${!branch_skip_var:-}" ]; then
104-
note "Found skip variable ${branch_skip_var} for branch ${VORTEX_DEPLOY_BRANCH}."
93+
# Branch names must match exactly as they appear in the repository.
94+
#
95+
# Examples:
96+
# VORTEX_DEPLOY_SKIP_BRANCHES=feature/test
97+
# VORTEX_DEPLOY_SKIP_BRANCHES=feature/test,hotfix/urgent,project/experimental
98+
if echo ",${VORTEX_DEPLOY_SKIP_BRANCHES}," | grep -qF ",${VORTEX_DEPLOY_BRANCH},"; then
99+
note "Found branch ${VORTEX_DEPLOY_BRANCH} in skip list."
105100
note "Skipping deployment ${VORTEX_DEPLOY_TYPES}."
106101
exit 0
107102
fi

0 commit comments

Comments
 (0)