Skip to content

Commit 014b9a0

Browse files
committed
Added support for imageSuffix in clone operation
1 parent 42654be commit 014b9a0

4 files changed

Lines changed: 42 additions & 1 deletion

File tree

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,19 @@ This GitHub Action creates or updates an environment in Quant Cloud.
1717
base_url: https://dashboard.quantcdn.io/api/v3 # Optional
1818
```
1919
20+
### Clone with Image Suffix (Feature Branches)
21+
22+
```yaml
23+
- uses: quantcdn/quant-cloud-environment-action@v1
24+
with:
25+
api_key: ${{ secrets.QUANT_API_KEY }}
26+
organization: your-org-id
27+
app_name: my-app
28+
environment_name: feature-xyz
29+
from_environment: production # Base configuration to clone from
30+
image_suffix: feature-xyz # Transforms "cli-latest" → "cli-feature-xyz"
31+
```
32+
2033
### Clone with Container Overrides
2134
2235
```yaml
@@ -88,6 +101,11 @@ This GitHub Action creates or updates an environment in Quant Cloud.
88101
* **Optional** - only used when creating a new environment
89102
* When provided, the new environment inherits all configuration from this source environment
90103
* `compose_spec` becomes optional and only used for selective container overrides
104+
* `image_suffix`: Suffix to automatically transform container image names
105+
* **Optional** - transforms image references during creation/updates
106+
* Example: `"feature-xyz"` transforms `"cli-latest"` → `"cli-feature-xyz"`
107+
* Works with both cloning (`from_environment`) and explicit compose specifications
108+
* Perfect for feature branch deployments with custom image tags
91109
* `base_url`: Quant Cloud API URL (optional, defaults to https://dashboard.quantcdn.io/api/v3)
92110

93111
## Outputs

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ inputs:
2626
compose_spec:
2727
description: 'Compose specification for the environment (required for updates, optional for new environments if from_environment is provided)'
2828
required: false
29+
image_suffix:
30+
description: 'Suffix to append to container image names (e.g. "feature-xyz" transforms "cli-latest" to "cli-feature-xyz")'
31+
required: false
2932
outputs:
3033
environment_name:
3134
description: 'The name of the created or updated environment'

dist/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63537,6 +63537,7 @@ async function run() {
6353763537
const baseUrl = core.getInput('base_url') || 'https://dashboard.quantcdn.io/api/v3';
6353863538
const fromEnvironment = core.getInput('from_environment', { required: false });
6353963539
const composeSpec = core.getInput('compose_spec', { required: false });
63540+
const imageSuffix = core.getInput('image_suffix', { required: false });
6354063541
let minCapacity = core.getInput('min_capacity', { required: false });
6354163542
let maxCapacity = core.getInput('max_capacity', { required: false });
6354263543
const client = new quant_ts_client_1.EnvironmentsApi(baseUrl);
@@ -63581,6 +63582,10 @@ async function run() {
6358163582
if (fromEnvironment) {
6358263583
createEnvironmentRequest.cloneConfigurationFrom = fromEnvironment;
6358363584
}
63585+
// Add image suffix if provided - API handles the transformation
63586+
if (imageSuffix) {
63587+
createEnvironmentRequest.imageSuffix = imageSuffix;
63588+
}
6358463589
// If neither composeSpec nor fromEnvironment provided, we need an empty compose definition
6358563590
if (!composeSpec && !fromEnvironment) {
6358663591
createEnvironmentRequest.composeDefinition = {};
@@ -63608,6 +63613,10 @@ async function run() {
6360863613
minCapacity: parseInt(minCapacity),
6360963614
maxCapacity: parseInt(maxCapacity),
6361063615
};
63616+
// Add image suffix if provided - API handles the transformation
63617+
if (imageSuffix) {
63618+
updateEnvironmentRequest.imageSuffix = imageSuffix;
63619+
}
6361163620
try {
6361263621
const response = await client.updateEnvironment(organisation, appName, environmentName, removeNullValues(updateEnvironmentRequest));
6361363622
core.info(`Successfully updated environment: ${environmentName}`);

src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ async function run(): Promise<void> {
6060

6161
const fromEnvironment = core.getInput('from_environment', { required: false });
6262
const composeSpec = core.getInput('compose_spec', { required: false });
63+
const imageSuffix = core.getInput('image_suffix', { required: false });
6364
let minCapacity = core.getInput('min_capacity', { required: false });
6465
let maxCapacity = core.getInput('max_capacity', { required: false });
6566
const client = new EnvironmentsApi(baseUrl);
@@ -111,6 +112,11 @@ async function run(): Promise<void> {
111112
createEnvironmentRequest.cloneConfigurationFrom = fromEnvironment;
112113
}
113114

115+
// Add image suffix if provided - API handles the transformation
116+
if (imageSuffix) {
117+
(createEnvironmentRequest as any).imageSuffix = imageSuffix;
118+
}
119+
114120
// If neither composeSpec nor fromEnvironment provided, we need an empty compose definition
115121
if (!composeSpec && !fromEnvironment) {
116122
createEnvironmentRequest.composeDefinition = {};
@@ -136,11 +142,16 @@ async function run(): Promise<void> {
136142
});
137143
}
138144

139-
const updateEnvironmentRequest = {
145+
const updateEnvironmentRequest: any = {
140146
composeDefinition,
141147
minCapacity: parseInt(minCapacity),
142148
maxCapacity: parseInt(maxCapacity),
143149
}
150+
151+
// Add image suffix if provided - API handles the transformation
152+
if (imageSuffix) {
153+
updateEnvironmentRequest.imageSuffix = imageSuffix;
154+
}
144155
try {
145156
const response = await client.updateEnvironment(organisation, appName, environmentName, removeNullValues(updateEnvironmentRequest));
146157
core.info(`Successfully updated environment: ${environmentName}`);

0 commit comments

Comments
 (0)