Skip to content

Commit 8dff69d

Browse files
Add labels support (#127)
* Add labels support * Remove RevisionMode * Revert accidental deletion * Update azure login to use UAMI with OIDC * Test update * Update description * Update arg * Add permissions * Add permissions * Remove builder steps * Add target labels params * Test commi * Add active revisions mode param * Add active revisions mode param * Add active revisions mode param * Remove oidc workflow * Add test log * Add target labels params * Remove oidc workflow * Update target label params * Update logs * Update param * Update logs * Update logs * Update index.js * Update index.js * Update index.js * Update workflow * Update workflow * Update comment * Update comment * Remove extra logs * Remove test branch * Remove unnecessary wait * Update with code review suggesstions * Remove extra log * Update index.js * Re-add a couple test valications * Update permissions * Add validation job * Remove test branch --------- Co-authored-by: William <[email protected]>
1 parent 5f5f4c5 commit 8dff69d

File tree

9 files changed

+703
-1177
lines changed

9 files changed

+703
-1177
lines changed

.github/workflows/run-validation-oidc.yml

Lines changed: 0 additions & 679 deletions
This file was deleted.

.github/workflows/run-validation.yml

Lines changed: 109 additions & 324 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ For more information on the structure of the YAML configuration file, please vis
177177
| `environmentVariables` | No | A list of environment variable(s) for the container. Space-separated values in 'key=value' format. Empty string to clear existing values. Prefix value with 'secretref:' to reference a secret. |
178178
| `ingress` | No | Possible options: external, internal, disabled. If set to "external" (default value if not provided when creating a Container App), the Container App will be visible from the internet or a VNET, depending on the app environment endpoint configured. If set to "internal", the Container App will be visible from within the app environment only. If set to "disabled", ingress will be disabled for this Container App and will not have an HTTP or TCP endpoint. |
179179
| `disableTelemetry` | No | If set to `true`, no telemetry will be collected by this GitHub Action. If set to `false`, or if this argument is not provided, telemetry will be sent to Microsoft about the Container App build and deploy scenario targeted by this GitHub Action. |
180+
| `TargetLabel` | No | The target label for new revisions. Will be injected into the YAML config under `properties.configuration.targetLabel` if provided. |
180181

181182
## Usage
182183

action.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,12 @@ inputs:
138138
not provided, telemetry will be sent to Microsoft about the Container App build and deploy scenario targeted by
139139
this GitHub Action.'
140140
required: false
141-
default: false
142-
141+
default: 'false'
142+
targetLabel:
143+
description: |
144+
'Specifies the target label for the Azure Container App revision.
145+
This will replace any prior revision with the given label. This is required when using ActiveRevisionMode: Labels.'
146+
required: false
143147
runs:
144148
using: 'node16'
145149
main: 'dist/index.js'

azurecontainerapps.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export class azurecontainerapps {
106106
private static buildArguments: string;
107107
private static noIngressUpdate: boolean;
108108
private static useInternalRegistry: boolean;
109+
private static targetLabel: string;
109110

110111
/**
111112
* Initializes the helpers used by this task.
@@ -160,6 +161,8 @@ export class azurecontainerapps {
160161
// Get the name of the image to build if it was provided, or generate it from build variables
161162
this.imageToBuild = this.toolHelper.getInput('imageToBuild', false);
162163

164+
this.targetLabel = this.toolHelper.getInput('targetLabel', false);
165+
163166
// Get the user defined build arguments, if provided
164167
this.buildArguments = this.toolHelper.getInput('buildArguments', false);
165168

@@ -545,6 +548,7 @@ export class azurecontainerapps {
545548
* file is not provided.
546549
*/
547550
private static setupContainerAppProperties() {
551+
this.toolHelper.writeDebug(`Setting up Container App properties...`);
548552
this.commandLineArgs = [];
549553

550554
// Get the ingress inputs
@@ -567,6 +571,15 @@ export class azurecontainerapps {
567571
`--registry-password ${this.registryPassword}`);
568572
}
569573

574+
575+
// Handle TargetLabel setup when activeRevisionsMode is Labels
576+
if (!this.util.isNullOrEmpty(this.targetLabel)) {
577+
this.toolHelper.writeDebug('Target label is provided. Setting up command line arguments for revisions mode "Labels".');
578+
579+
// If the target label is provided, add it to the command line arguments
580+
this.commandLineArgs.push(`--revisions-mode Labels`, `--target-label ${this.targetLabel}`);
581+
}
582+
570583
// Determine default values only for the 'create' scenario to avoid overriding existing values for the 'update' scenario
571584
if (!this.containerAppExists) {
572585
this.ingressEnabled = true;
@@ -619,18 +632,24 @@ export class azurecontainerapps {
619632
this.commandLineArgs.push(`-i ${this.imageToDeploy}`);
620633
} else if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry) {
621634
this.commandLineArgs.push(`--source ${this.appSourcePath}`);
635+
} else if (!this.util.isNullOrEmpty(this.targetLabel)) {
636+
// If the target label is provided, add it to the command line arguments
637+
this.commandLineArgs.push(`--revisions-mode Labels`, `--target-label ${this.targetLabel}`);
622638
}
623639
}
624640

625641
/**
626642
* Creates or updates the Container App.
627643
*/
628644
private static async createOrUpdateContainerApp() {
645+
this.toolHelper.writeInfo(`Creating or updating Container App "${this.containerAppName}" in resource group "${this.resourceGroup}"...`);
629646
if (!this.containerAppExists) {
630647
if (!this.util.isNullOrEmpty(this.yamlConfigPath)) {
648+
this.toolHelper.writeInfo(`Creating Container App "${this.containerAppName}" from YAML configuration file "${this.yamlConfigPath}"...`);
631649
// Create the Container App from the YAML configuration file
632650
await this.appHelper.createContainerAppFromYaml(this.containerAppName, this.resourceGroup, this.yamlConfigPath);
633651
} else {
652+
this.toolHelper.writeInfo(`Creating Container App "${this.containerAppName}" from command line arguments...`);
634653
// Create the Container App from command line arguments
635654
await this.appHelper.createContainerApp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.commandLineArgs);
636655
}

0 commit comments

Comments
 (0)