From 4e84426311f5cea784d0ef99207293b7052f9cfc Mon Sep 17 00:00:00 2001 From: snehapar9 <108305436+snehapar9@users.noreply.github.com> Date: Mon, 6 Nov 2023 22:56:53 -0800 Subject: [PATCH 01/12] Support private registry scenario (#69) * Initial commit to support private registry scenario * Add global var to delegate build to CLI * Update condition to use CLI * Fix formatting * Update validation for internal registry scenario * Address PR comments * Update condition to use internal registry * Test validation for internal registry scenario * Get value of imageToBuild before build * Fetch imageToBuild arg and test * Move code to fetch imageToBuild in validation * Install extension * Trigger pipeline * Re-trigger pipeline to install extensions * Re-trigger pipeline to isntall extension * Install extension and re-trigger pipeline * Explicitly install extension * Trigger pipeline * Re-trigger pipeline * Change whl name * Fix pipeline failure and re-trigger * Fix pipeline failures * Install extension explicitly * Fix valiation failures * Fix validation failures * Test validation failures * Test validation failures * Remove location * Test validation pipeline * Test validation pipeline * Test validation pipeline * Test validation pipeline * Test validation pipeline * Trigger validation pipeline * Test validation pipeline * Address validation failures * Address PR discussion comments * Made `imageToDeploy` optional * Remove step to install whl * Address PR comments * Addressed PR comments * Fix typo * Remove space * Fix merge failure * Remove --debug * Test registry scenario * Fix merge failures and re-trigger pipeline * Add --debug * Create containerapp with up * Create container app with up * Trigger validation pipeline * Test container app creation with up * Add location to up command * Use up for just private registry scenario * Change rg for update scenario * Remove step to delete pushed image * Test containerapp update with up * Hardcode location to northcentralusstage * Remove app source path --------- Co-authored-by: Cormac McCarthy --- .github/workflows/run-validation.yml | 129 +++--- README.md | 1 - action.yml | 7 - azurecontainerapps.ts | 87 ++-- dist/index.js | 573 ++++++++++++++------------- src/ContainerAppHelper.ts | 58 +-- src/Utility.ts | 5 +- 7 files changed, 458 insertions(+), 402 deletions(-) diff --git a/.github/workflows/run-validation.yml b/.github/workflows/run-validation.yml index efb5b534..d7a964aa 100644 --- a/.github/workflows/run-validation.yml +++ b/.github/workflows/run-validation.yml @@ -59,10 +59,45 @@ jobs: shell: bash run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y - - name: Delete pushed image + + create-using-builder-and-internal-registry: + name: 'Create app using builder and push to internal registry' + runs-on: ubuntu-latest + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'bs-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-${{ github.run_id }}' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Log in to Azure + uses: azure/login@v1 + with: + creds: ${{ secrets.TEST_AZURE_CREDENTIALS }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NO_ACR_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App if: ${{ always() }} shell: bash - run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + create-using-found-dockerfile: name: 'Create app using found Dockerfile' @@ -106,11 +141,6 @@ jobs: shell: bash run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y - - name: Delete pushed image - if: ${{ always() }} - shell: bash - run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y - create-using-provided-dockerfile: name: 'Create app using provided Dockerfile' runs-on: ubuntu-latest @@ -154,11 +184,6 @@ jobs: shell: bash run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y - - name: Delete pushed image - if: ${{ always() }} - shell: bash - run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y - create-using-image-linux: name: 'Create app using image on Linux runner' @@ -280,15 +305,14 @@ jobs: shell: bash run: az monitor log-analytics workspace delete -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -n ${{ env.WORKSPACE_NAME }} -y - create-using-builder-yaml: - name: 'Create app using builder with YAML configuration' + create-using-image-yaml-linux: + name: 'Create app using image with YAML configuration on Linux runner' runs-on: ubuntu-latest timeout-minutes: 10 env: - TEST_IMAGE_TAG: 'bs-yaml-${{ github.run_id }}' - TEST_CONTAINER_APP_NAME: 'gh-ca-bs-yaml-${{ github.run_id }}' - TEST_YAML_FILE_PATH: '${{ github.workspace }}/yaml-samples/create-with-builder-simple.yaml' + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-yaml-lin-${{ github.run_id }}' + TEST_YAML_FILE_PATH: '${{ github.workspace }}/yaml-samples/create-with-image-simple.yaml' steps: - name: Checkout action repository @@ -311,23 +335,13 @@ jobs: (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$SUBSCRIPTION_ID$', '${{ vars.TEST_SUBSCRIPTION_ID }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$RESOURCE_GROUP$', '${{ vars.TEST_RESOURCE_GROUP_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$CONTAINER_APP_ENV$', '${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} - (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$FULL_ACR_NAME$', '${{ env.TEST_FULL_ACR_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} - (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$ACR_USERNAME$', '${{ secrets.TEST_REGISTRY_USERNAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} - (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$ACR_PASSWORD$', '${{ secrets.TEST_REGISTRY_PASSWORD }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} - (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$IMAGE_REPOSITORY$', '${{ env.TEST_IMAGE_REPOSITORY }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} - (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$IMAGE_TAG$', '${{ env.TEST_IMAGE_TAG }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} - name: Execute Azure Container Apps Build and Deploy Action uses: ./ with: yamlConfigPath: ${{ env.TEST_YAML_FILE_PATH }} - appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' - acrName: ${{ vars.TEST_ACR_NAME }} - acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} - acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} - imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} - name: Delete created Azure Container App @@ -335,19 +349,14 @@ jobs: shell: bash run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y - - name: Delete pushed image - if: ${{ always() }} - shell: bash - run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y - - create-using-image-yaml-linux: - name: 'Create app using image with YAML configuration on Linux runner' - runs-on: ubuntu-latest + create-using-image-yaml-windows: + name: 'Create app using image with YAML configuration on Windows runner' + runs-on: windows-latest timeout-minutes: 10 env: - TEST_CONTAINER_APP_NAME: 'gh-ca-bs-yaml-lin-${{ github.run_id }}' - TEST_YAML_FILE_PATH: '${{ github.workspace }}/yaml-samples/create-with-image-simple.yaml' + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-yaml-win-${{ github.run_id }}' + TEST_YAML_FILE_PATH: 'yaml-samples/create-with-image-simple.yaml' steps: - name: Checkout action repository @@ -384,14 +393,14 @@ jobs: shell: bash run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y - create-using-image-yaml-windows: - name: 'Create app using image with YAML configuration on Windows runner' - runs-on: windows-latest + update-using-builder: + name: 'Update existing app using builder' + runs-on: ubuntu-latest timeout-minutes: 10 env: - TEST_CONTAINER_APP_NAME: 'gh-ca-bs-yaml-win-${{ github.run_id }}' - TEST_YAML_FILE_PATH: 'yaml-samples/create-with-image-simple.yaml' + TEST_IMAGE_TAG: 'bs-up-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'update-using-builder-app' steps: - name: Checkout action repository @@ -408,28 +417,26 @@ jobs: with: creds: ${{ secrets.TEST_AZURE_CREDENTIALS }} - - name: Update values in YAML configuration file - shell: pwsh - run: | - (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$SUBSCRIPTION_ID$', '${{ vars.TEST_SUBSCRIPTION_ID }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} - (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$RESOURCE_GROUP$', '${{ vars.TEST_RESOURCE_GROUP_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} - (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$CONTAINER_APP_ENV$', '${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} - - name: Execute Azure Container Apps Build and Deploy Action uses: ./ with: - yamlConfigPath: ${{ env.TEST_YAML_FILE_PATH }} + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + acrName: ${{ vars.TEST_ACR_NAME }} + acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} + acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} - - name: Delete created Azure Container App + - name: Update Container App with existing image if: ${{ always() }} shell: bash - run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + run: az containerapp update -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -i mcr.microsoft.com/azuredocs/containerapps-helloworld:latest - update-using-builder: - name: 'Update existing app using builder' + update-using-builder-and-internal-registry: + name: 'Update existing app using builder and push to internal registry' runs-on: ubuntu-latest timeout-minutes: 10 @@ -456,20 +463,11 @@ jobs: uses: ./ with: appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' - acrName: ${{ vars.TEST_ACR_NAME }} - acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} - acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} - containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppName: ${{ env.TEST_EXISTING_CONTAINER_APP }} containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} - resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} - imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NO_ACR_NAME }} disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} - - name: Delete pushed image - if: ${{ always() }} - shell: bash - run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y - - name: Update Container App with existing image if: ${{ always() }} shell: bash @@ -503,7 +501,6 @@ jobs: disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} update-using-image-yaml: - name: 'Update app using image with YAML configuration' runs-on: ubuntu-latest timeout-minutes: 10 diff --git a/README.md b/README.md index 63c5536a..8f721a95 100644 --- a/README.md +++ b/README.md @@ -171,7 +171,6 @@ For more information on the structure of the YAML configuration file, please vis | `containerAppEnvironment` | No | The name of the Container App environment to use with the application. If not provided, an existing environment in the resource group of the Container App will be used, otherwise, an environment will be created in the formation `-env`. | | `runtimeStack` | No | The platform version stack used in the final runnable application image that is deployed to the Container App. The value should be provided in the formation `:`. If not provided, this value is determined by Oryx based on the contents of the provided application. Please refer to [this document](https://github.com/microsoft/Oryx/blob/main/doc/supportedRuntimeVersions.md) for more information on supported runtime stacks for Oryx. | | `builderStack` | No | The stack (OS) that should be used to build the provided application source and produce the runnable application image. You can provide a specific image tag for the stack, such as "debian-bookworm-20231004.1", or you can provide a supported stack name, such as "debian-bookworm" or "debian-bullseye", and the latest supported image tag for that stack will be used. If no stack is provided, this action will attempt to build the provided application source with each supported stack until there's a successful build. | -| `buildArguments` | No | A list of build arguments provided as KEY=VALUE pairings and are comma-separated. If a Dockerfile has been provided or is discovered in the application source, each build argument will be passed to the `docker build` command via the `--build-arg` flag. If the Oryx++ builder is used to create a runnable application image, each build argument will be passed to the `pack build` command via the `--env` flag. | | `targetPort` | No | The designated port for the application to run on. If no value is provided and the builder is used to build the runnable application image, the target port will be set to 80 for Python applications and 8080 for all other platform applications. If no value is provided when creating a Container App, the target port will default to 80. Note: when using this action to update a Container App, the target port may be updated if not provided based on changes to the ingress property. | | `location` | No | The location that the Container App (and other created resources) will be deployed to. To view locations suitable for creating the Container App in, please run the following: `az provider show -n Microsoft.App --query "resourceTypes[?resourceType=='containerApps'].locations"` | | `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. | diff --git a/action.yml b/action.yml index 2fe3fe19..384bff60 100644 --- a/action.yml +++ b/action.yml @@ -88,13 +88,6 @@ inputs: for that stack will be used. If no stack is provided, this action will attempt to build the provided application source with each supported stack until there's a successful build.' required: false - buildArguments: - description: | - 'A list of build arguments provided as KEY=VALUE pairings and are comma-separated. If a Dockerfile has been - provided or is discovered in the application source, each build argument will be passed to the "docker build" - command via the --build-arg flag. If the Oryx++ builder is used to create a runnable application image, each - build argument will be passed to the "pack build" command via the --env flag.' - required: false targetPort: description: | 'The designated port for the application to run on. If no value is provided and the builder is used to build the diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index bd119a74..9110f738 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -21,7 +21,7 @@ export class azurecontainerapps { // Set up the resources required to deploy a Container App await this.setupResources(); - // If a Container Registry URL was provided, try to authenticate against it + // If a Container Registry URL was provided, try to authenticate against it if (!this.util.isNullOrEmpty(this.registryUrl)) { await this.authenticateContainerRegistryAsync(); } @@ -31,8 +31,17 @@ export class azurecontainerapps { await this.authenticateAzureContainerRegistryAsync(); } + // Set up the Container App Image properties if it's not provided by the user. + this.setupContainerAppImageProperties(); + + const useAzureContainerRegistry = !this.util.isNullOrEmpty(this.registryUrl) && this.registryUrl.endsWith('.azurecr.io'); + this.useInternalRegistry = this.util.isNullOrEmpty(this.registryUrl) && this.imageToBuild.startsWith(this.defaultRegistryServer); + + // Determine if the image should be built and pushed using the CLI + this.useCliToBuildAndPushImage = (useAzureContainerRegistry || this.useInternalRegistry); + // If the application source was provided, build a runnable application image from it - if (!this.util.isNullOrEmpty(this.appSourcePath)) { + if (!this.useCliToBuildAndPushImage && !this.util.isNullOrEmpty(this.appSourcePath)) { await this.buildAndPushImageAsync(); } @@ -98,6 +107,9 @@ export class azurecontainerapps { private static ingress: string; private static targetPort: string; private static shouldUseUpdateCommand: boolean; + private static useCliToBuildAndPushImage: boolean; + private static defaultRegistryServer: string = 'default/'; + private static useInternalRegistry: boolean; /** * Initializes the helpers used by this task. @@ -149,12 +161,8 @@ export class azurecontainerapps { // Get the YAML configuration file, if provided this.yamlConfigPath = this.toolHelper.getInput('yamlConfigPath', false) as string; - // Ensure that acrName or registryUrl is also provided if appSourcePath is provided - if (!this.util.isNullOrEmpty(this.appSourcePath) && this.util.isNullOrEmpty(this.acrName) && this.util.isNullOrEmpty(this.registryUrl)) { - let missingRegistryUrlMessage = `The 'acrName' or 'registryUrl' argument must be provided when the 'appSourcePath' argument is provided.`; - this.toolHelper.writeError(missingRegistryUrlMessage); - throw Error(missingRegistryUrlMessage); - } + // Get the name of the image to build if it was provided, or generate it from build variables + this.imageToBuild = this.toolHelper.getInput('imageToBuild', false); // Ensure that one of appSourcePath, imageToDeploy, or yamlConfigPath is provided if (this.util.isNullOrEmpty(this.appSourcePath) && this.util.isNullOrEmpty(this.imageToDeploy) && this.util.isNullOrEmpty(this.yamlConfigPath)) { @@ -342,16 +350,18 @@ export class azurecontainerapps { // If telemetry is enabled, log that the previously built image scenario was targeted for this task this.telemetryHelper.setImageScenario(); } - /** - * Builds a runnable application image using a Dockerfile or the builder and pushes it to the Container Registry. - */ - private static async buildAndPushImageAsync() { + * Sets up the Container App Image properties if it's not provided by the user. + */ + private static setupContainerAppImageProperties() { // Get the name of the image to build if it was provided, or generate it from build variables this.imageToBuild = this.toolHelper.getInput('imageToBuild', false); + if (this.util.isNullOrEmpty(this.imageToBuild)) { const imageRepository = this.toolHelper.getDefaultImageRepository() - this.imageToBuild = `${this.registryUrl}/${imageRepository}:${this.buildId}.${this.buildNumber}`; + // Constructs the image to build based on the provided registry URL, image repository, build ID, and build number. + // If the registry URL is not provided or is empty, the default registry server is used; otherwise, the provided registry URL is used. + this.imageToBuild = this.util.isNullOrEmpty(this.registryUrl) ? `${this.defaultRegistryServer}${imageRepository}:${this.buildId}.${this.buildNumber}` : `${this.registryUrl}/${imageRepository}:${this.buildId}.${this.buildNumber}`; this.toolHelper.writeInfo(`Default image to build: ${this.imageToBuild}`); } @@ -360,14 +370,12 @@ export class azurecontainerapps { this.imageToDeploy = this.imageToBuild; this.toolHelper.writeInfo(`Default image to deploy: ${this.imageToDeploy}`); } + } - // Set up the build arguments to pass to the Dockerfile or builder - let buildArguments: string[] = []; - const buildArgumentsValue = this.toolHelper.getInput('buildArguments', false); - if (!this.util.isNullOrEmpty(buildArgumentsValue)) { - buildArguments = buildArgumentsValue.split(','); - } - + /** + * Builds a runnable application image using a Dockerfile or the builder and pushes it to the Container Registry. + */ + private static async buildAndPushImageAsync() { // Get Dockerfile to build, if provided, or check if one exists at the root of the provided application let dockerfilePath: string = this.toolHelper.getInput('dockerfilePath', false); if (this.util.isNullOrEmpty(dockerfilePath)) { @@ -378,7 +386,7 @@ export class azurecontainerapps { dockerfilePath = rootDockerfilePath; } else { // No Dockerfile found or provided, build the image using the builder - await this.buildImageFromBuilderAsync(this.appSourcePath, this.imageToBuild, buildArguments); + await this.buildImageFromBuilderAsync(this.appSourcePath, this.imageToBuild); } } else { dockerfilePath = path.join(this.appSourcePath, dockerfilePath); @@ -386,7 +394,7 @@ export class azurecontainerapps { if (!this.util.isNullOrEmpty(dockerfilePath)) { // Build the image from the provided/discovered Dockerfile - await this.buildImageFromDockerfile(this.appSourcePath, dockerfilePath, this.imageToBuild, buildArguments); + await this.buildImageFromDockerfile(this.appSourcePath, dockerfilePath, this.imageToBuild); } // Push the image to the Container Registry @@ -397,9 +405,8 @@ export class azurecontainerapps { * Builds a runnable application image using the builder. * @param appSourcePath - The path to the application source code. * @param imageToBuild - The name of the image to build. - * @param buildArguments - The build arguments to pass to the builder. */ - private static async buildImageFromBuilderAsync(appSourcePath: string, imageToBuild: string, buildArguments: string[]) { + private static async buildImageFromBuilderAsync(appSourcePath: string, imageToBuild: string) { // Install the pack CLI await this.appHelper.installPackCliAsync(); this.toolHelper.writeInfo(`Successfully installed the pack CLI.`); @@ -429,11 +436,6 @@ export class azurecontainerapps { environmentVariables.push(`ORYX_RUNTIME_PORT=${this.targetPort}`); } - // Provide any additional build arguments to the builder - if (buildArguments.length > 0) { - environmentVariables = environmentVariables.concat(buildArguments); - } - this.toolHelper.writeInfo(`Building image "${imageToBuild}" using the Oryx++ Builder`); // Set the Oryx++ Builder as the default builder locally @@ -451,15 +453,13 @@ export class azurecontainerapps { * @param appSourcePath - The path to the application source code. * @param dockerfilePath - The path to the Dockerfile to build. * @param imageToBuild - The name of the image to build. - * @param buildArguments - The build arguments to pass to the Dockerfile. */ private static async buildImageFromDockerfile( appSourcePath: string, dockerfilePath: string, - imageToBuild: string, - buildArguments: string[]) { + imageToBuild: string) { this.toolHelper.writeInfo(`Building image "${imageToBuild}" using the provided Dockerfile`); - await this.appHelper.createRunnableAppImageFromDockerfile(imageToBuild, appSourcePath, dockerfilePath, buildArguments); + await this.appHelper.createRunnableAppImageFromDockerfile(imageToBuild, appSourcePath, dockerfilePath); // If telemetry is enabled, log that the Dockerfile scenario was targeted for this task this.telemetryHelper.setDockerfileScenario(); @@ -537,19 +537,30 @@ export class azurecontainerapps { this.commandLineArgs.push(`--env-vars ${environmentVariables}`); } } + + if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { + this.commandLineArgs.push(`-i ${this.imageToDeploy}`); + } + + if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { + this.commandLineArgs.push(`--source ${this.appSourcePath}`); + } } /** * Creates or updates the Container App. */ private static async createOrUpdateContainerApp() { + var createOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry if (!this.containerAppExists) { if (!this.util.isNullOrEmpty(this.yamlConfigPath)) { // Create the Container App from the YAML configuration file await this.appHelper.createContainerAppFromYaml(this.containerAppName, this.resourceGroup, this.yamlConfigPath); + } else if (createOrUpdateContainerAppWithUp) { + await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs); } else { // Create the Container App from command line arguments - await this.appHelper.createContainerApp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.imageToDeploy, this.commandLineArgs); + await this.appHelper.createContainerApp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.commandLineArgs); } return; @@ -562,17 +573,19 @@ export class azurecontainerapps { return; } - if (this.shouldUseUpdateCommand) { + if (this.shouldUseUpdateCommand && !createOrUpdateContainerAppWithUp) { // Update the Container Registry details on the existing Container App, if provided as an input if (!this.util.isNullOrEmpty(this.registryUrl) && !this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword)) { await this.appHelper.updateContainerAppRegistryDetails(this.containerAppName, this.resourceGroup, this.registryUrl, this.registryUsername, this.registryPassword); } // Update the Container App using the 'update' command - await this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.imageToDeploy, this.commandLineArgs); + await this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.commandLineArgs); + } else if (createOrUpdateContainerAppWithUp) { + await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs); } else { // Update the Container App using the 'up' command - await this.appHelper.updateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.imageToDeploy, this.commandLineArgs, this.ingress, this.targetPort); + await this.appHelper.updateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs, this.ingress, this.targetPort); } // Disable ingress on the existing Container App, if provided as an input diff --git a/dist/index.js b/dist/index.js index 634c17a3..26ee397f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,7 +1,7 @@ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ -/***/ 7595: +/***/ 3238: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -46,17 +46,17 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.azurecontainerapps = void 0; var fs = __nccwpck_require__(7147); var path = __nccwpck_require__(1017); -var ContainerAppHelper_1 = __nccwpck_require__(1621); -var ContainerRegistryHelper_1 = __nccwpck_require__(2673); -var TelemetryHelper_1 = __nccwpck_require__(7893); -var Utility_1 = __nccwpck_require__(5077); -var GitHubActionsToolHelper_1 = __nccwpck_require__(5119); +var ContainerAppHelper_1 = __nccwpck_require__(2929); +var ContainerRegistryHelper_1 = __nccwpck_require__(4769); +var TelemetryHelper_1 = __nccwpck_require__(7166); +var Utility_1 = __nccwpck_require__(2135); +var GitHubActionsToolHelper_1 = __nccwpck_require__(3185); var azurecontainerapps = /** @class */ (function () { function azurecontainerapps() { } azurecontainerapps.runMain = function () { return __awaiter(this, void 0, void 0, function () { - var err_1; + var useAzureContainerRegistry, err_1; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -88,7 +88,13 @@ var azurecontainerapps = /** @class */ (function () { _a.sent(); _a.label = 7; case 7: - if (!!this.util.isNullOrEmpty(this.appSourcePath)) return [3 /*break*/, 9]; + // Set up the Container App Image properties if it's not provided by the user. + this.setupContainerAppImageProperties(); + useAzureContainerRegistry = !this.util.isNullOrEmpty(this.registryUrl) && this.registryUrl.endsWith('.azurecr.io'); + this.useInternalRegistry = this.util.isNullOrEmpty(this.registryUrl) && this.imageToBuild.startsWith(this.defaultRegistryServer); + // Determine if the image should be built and pushed using the CLI + this.useCliToBuildAndPushImage = (useAzureContainerRegistry || this.useInternalRegistry); + if (!(!this.useCliToBuildAndPushImage && !this.util.isNullOrEmpty(this.appSourcePath))) return [3 /*break*/, 9]; return [4 /*yield*/, this.buildAndPushImageAsync()]; case 8: _a.sent(); @@ -163,12 +169,8 @@ var azurecontainerapps = /** @class */ (function () { this.imageToDeploy = this.toolHelper.getInput('imageToDeploy', false); // Get the YAML configuration file, if provided this.yamlConfigPath = this.toolHelper.getInput('yamlConfigPath', false); - // Ensure that acrName or registryUrl is also provided if appSourcePath is provided - if (!this.util.isNullOrEmpty(this.appSourcePath) && this.util.isNullOrEmpty(this.acrName) && this.util.isNullOrEmpty(this.registryUrl)) { - var missingRegistryUrlMessage = "The 'acrName' or 'registryUrl' argument must be provided when the 'appSourcePath' argument is provided."; - this.toolHelper.writeError(missingRegistryUrlMessage); - throw Error(missingRegistryUrlMessage); - } + // Get the name of the image to build if it was provided, or generate it from build variables + this.imageToBuild = this.toolHelper.getInput('imageToBuild', false); // Ensure that one of appSourcePath, imageToDeploy, or yamlConfigPath is provided if (this.util.isNullOrEmpty(this.appSourcePath) && this.util.isNullOrEmpty(this.imageToDeploy) && this.util.isNullOrEmpty(this.yamlConfigPath)) { var requiredArgumentMessage = "One of the following arguments must be provided: 'appSourcePath', 'imageToDeploy', or 'yamlConfigPath'."; @@ -411,32 +413,34 @@ var azurecontainerapps = /** @class */ (function () { // If telemetry is enabled, log that the previously built image scenario was targeted for this task this.telemetryHelper.setImageScenario(); }; + /** + * Sets up the Container App Image properties if it's not provided by the user. + */ + azurecontainerapps.setupContainerAppImageProperties = function () { + // Get the name of the image to build if it was provided, or generate it from build variables + this.imageToBuild = this.toolHelper.getInput('imageToBuild', false); + if (this.util.isNullOrEmpty(this.imageToBuild)) { + var imageRepository = this.toolHelper.getDefaultImageRepository(); + // Constructs the image to build based on the provided registry URL, image repository, build ID, and build number. + // If the registry URL is not provided or is empty, the default registry server is used; otherwise, the provided registry URL is used. + this.imageToBuild = this.util.isNullOrEmpty(this.registryUrl) ? "".concat(this.defaultRegistryServer).concat(imageRepository, ":").concat(this.buildId, ".").concat(this.buildNumber) : "".concat(this.registryUrl, "/").concat(imageRepository, ":").concat(this.buildId, ".").concat(this.buildNumber); + this.toolHelper.writeInfo("Default image to build: ".concat(this.imageToBuild)); + } + // Get the name of the image to deploy if it was provided, or set it to the value of 'imageToBuild' + if (this.util.isNullOrEmpty(this.imageToDeploy)) { + this.imageToDeploy = this.imageToBuild; + this.toolHelper.writeInfo("Default image to deploy: ".concat(this.imageToDeploy)); + } + }; /** * Builds a runnable application image using a Dockerfile or the builder and pushes it to the Container Registry. */ azurecontainerapps.buildAndPushImageAsync = function () { return __awaiter(this, void 0, void 0, function () { - var imageRepository, buildArguments, buildArgumentsValue, dockerfilePath, rootDockerfilePath; + var dockerfilePath, rootDockerfilePath; return __generator(this, function (_a) { switch (_a.label) { case 0: - // Get the name of the image to build if it was provided, or generate it from build variables - this.imageToBuild = this.toolHelper.getInput('imageToBuild', false); - if (this.util.isNullOrEmpty(this.imageToBuild)) { - imageRepository = this.toolHelper.getDefaultImageRepository(); - this.imageToBuild = "".concat(this.registryUrl, "/").concat(imageRepository, ":").concat(this.buildId, ".").concat(this.buildNumber); - this.toolHelper.writeInfo("Default image to build: ".concat(this.imageToBuild)); - } - // Get the name of the image to deploy if it was provided, or set it to the value of 'imageToBuild' - if (this.util.isNullOrEmpty(this.imageToDeploy)) { - this.imageToDeploy = this.imageToBuild; - this.toolHelper.writeInfo("Default image to deploy: ".concat(this.imageToDeploy)); - } - buildArguments = []; - buildArgumentsValue = this.toolHelper.getInput('buildArguments', false); - if (!this.util.isNullOrEmpty(buildArgumentsValue)) { - buildArguments = buildArgumentsValue.split(','); - } dockerfilePath = this.toolHelper.getInput('dockerfilePath', false); if (!this.util.isNullOrEmpty(dockerfilePath)) return [3 /*break*/, 4]; this.toolHelper.writeInfo("No Dockerfile path provided; checking for Dockerfile at root of application source."); @@ -447,7 +451,7 @@ var azurecontainerapps = /** @class */ (function () { return [3 /*break*/, 3]; case 1: // No Dockerfile found or provided, build the image using the builder - return [4 /*yield*/, this.buildImageFromBuilderAsync(this.appSourcePath, this.imageToBuild, buildArguments)]; + return [4 /*yield*/, this.buildImageFromBuilderAsync(this.appSourcePath, this.imageToBuild)]; case 2: // No Dockerfile found or provided, build the image using the builder _a.sent(); @@ -459,7 +463,7 @@ var azurecontainerapps = /** @class */ (function () { case 5: if (!!this.util.isNullOrEmpty(dockerfilePath)) return [3 /*break*/, 7]; // Build the image from the provided/discovered Dockerfile - return [4 /*yield*/, this.buildImageFromDockerfile(this.appSourcePath, dockerfilePath, this.imageToBuild, buildArguments)]; + return [4 /*yield*/, this.buildImageFromDockerfile(this.appSourcePath, dockerfilePath, this.imageToBuild)]; case 6: // Build the image from the provided/discovered Dockerfile _a.sent(); @@ -479,9 +483,8 @@ var azurecontainerapps = /** @class */ (function () { * Builds a runnable application image using the builder. * @param appSourcePath - The path to the application source code. * @param imageToBuild - The name of the image to build. - * @param buildArguments - The build arguments to pass to the builder. */ - azurecontainerapps.buildImageFromBuilderAsync = function (appSourcePath, imageToBuild, buildArguments) { + azurecontainerapps.buildImageFromBuilderAsync = function (appSourcePath, imageToBuild) { return __awaiter(this, void 0, void 0, function () { var environmentVariables, runtimeStack, runtimeStackSplit, platformName, platformVersion, builderStack; return __generator(this, function (_a) { @@ -513,10 +516,6 @@ var azurecontainerapps = /** @class */ (function () { if (!this.util.isNullOrEmpty(this.targetPort)) { environmentVariables.push("ORYX_RUNTIME_PORT=".concat(this.targetPort)); } - // Provide any additional build arguments to the builder - if (buildArguments.length > 0) { - environmentVariables = environmentVariables.concat(buildArguments); - } this.toolHelper.writeInfo("Building image \"".concat(imageToBuild, "\" using the Oryx++ Builder")); // Set the Oryx++ Builder as the default builder locally return [4 /*yield*/, this.appHelper.setDefaultBuilder()]; @@ -540,15 +539,14 @@ var azurecontainerapps = /** @class */ (function () { * @param appSourcePath - The path to the application source code. * @param dockerfilePath - The path to the Dockerfile to build. * @param imageToBuild - The name of the image to build. - * @param buildArguments - The build arguments to pass to the Dockerfile. */ - azurecontainerapps.buildImageFromDockerfile = function (appSourcePath, dockerfilePath, imageToBuild, buildArguments) { + azurecontainerapps.buildImageFromDockerfile = function (appSourcePath, dockerfilePath, imageToBuild) { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: this.toolHelper.writeInfo("Building image \"".concat(imageToBuild, "\" using the provided Dockerfile")); - return [4 /*yield*/, this.appHelper.createRunnableAppImageFromDockerfile(imageToBuild, appSourcePath, dockerfilePath, buildArguments)]; + return [4 /*yield*/, this.appHelper.createRunnableAppImageFromDockerfile(imageToBuild, appSourcePath, dockerfilePath)]; case 1: _a.sent(); // If telemetry is enabled, log that the Dockerfile scenario was targeted for this task @@ -617,71 +615,92 @@ var azurecontainerapps = /** @class */ (function () { this.commandLineArgs.push("--env-vars ".concat(environmentVariables)); } } + if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { + this.commandLineArgs.push("-i ".concat(this.imageToDeploy)); + } + if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { + this.commandLineArgs.push("--source ".concat(this.appSourcePath)); + } }; /** * Creates or updates the Container App. */ azurecontainerapps.createOrUpdateContainerApp = function () { return __awaiter(this, void 0, void 0, function () { + var createOrUpdateContainerAppWithUp; return __generator(this, function (_a) { switch (_a.label) { case 0: - if (!!this.containerAppExists) return [3 /*break*/, 5]; + createOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry; + if (!!this.containerAppExists) return [3 /*break*/, 7]; if (!!this.util.isNullOrEmpty(this.yamlConfigPath)) return [3 /*break*/, 2]; // Create the Container App from the YAML configuration file return [4 /*yield*/, this.appHelper.createContainerAppFromYaml(this.containerAppName, this.resourceGroup, this.yamlConfigPath)]; case 1: // Create the Container App from the YAML configuration file _a.sent(); - return [3 /*break*/, 4]; - case 2: - // Create the Container App from command line arguments - return [4 /*yield*/, this.appHelper.createContainerApp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.imageToDeploy, this.commandLineArgs)]; + return [3 /*break*/, 6]; + case 2: + if (!createOrUpdateContainerAppWithUp) return [3 /*break*/, 4]; + return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs)]; case 3: - // Create the Container App from command line arguments _a.sent(); - _a.label = 4; - case 4: return [2 /*return*/]; + return [3 /*break*/, 6]; + case 4: + // Create the Container App from command line arguments + return [4 /*yield*/, this.appHelper.createContainerApp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.commandLineArgs)]; case 5: - if (!!this.util.isNullOrEmpty(this.yamlConfigPath)) return [3 /*break*/, 7]; + // Create the Container App from command line arguments + _a.sent(); + _a.label = 6; + case 6: return [2 /*return*/]; + case 7: + if (!!this.util.isNullOrEmpty(this.yamlConfigPath)) return [3 /*break*/, 9]; // Update the Container App from the YAML configuration file return [4 /*yield*/, this.appHelper.updateContainerAppFromYaml(this.containerAppName, this.resourceGroup, this.yamlConfigPath)]; - case 6: + case 8: // Update the Container App from the YAML configuration file _a.sent(); return [2 /*return*/]; - case 7: - if (!this.shouldUseUpdateCommand) return [3 /*break*/, 11]; - if (!(!this.util.isNullOrEmpty(this.registryUrl) && !this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword))) return [3 /*break*/, 9]; + case 9: + if (!(this.shouldUseUpdateCommand && !createOrUpdateContainerAppWithUp)) return [3 /*break*/, 13]; + if (!(!this.util.isNullOrEmpty(this.registryUrl) && !this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword))) return [3 /*break*/, 11]; return [4 /*yield*/, this.appHelper.updateContainerAppRegistryDetails(this.containerAppName, this.resourceGroup, this.registryUrl, this.registryUsername, this.registryPassword)]; - case 8: + case 10: _a.sent(); - _a.label = 9; - case 9: + _a.label = 11; + case 11: // Update the Container App using the 'update' command - return [4 /*yield*/, this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.imageToDeploy, this.commandLineArgs)]; - case 10: + return [4 /*yield*/, this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.commandLineArgs)]; + case 12: // Update the Container App using the 'update' command _a.sent(); - return [3 /*break*/, 13]; - case 11: + return [3 /*break*/, 17]; + case 13: + if (!createOrUpdateContainerAppWithUp) return [3 /*break*/, 15]; + return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs)]; + case 14: + _a.sent(); + return [3 /*break*/, 17]; + case 15: // Update the Container App using the 'up' command - return [4 /*yield*/, this.appHelper.updateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.imageToDeploy, this.commandLineArgs, this.ingress, this.targetPort)]; - case 12: + return [4 /*yield*/, this.appHelper.updateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs, this.ingress, this.targetPort)]; + case 16: // Update the Container App using the 'up' command _a.sent(); - _a.label = 13; - case 13: - if (!(this.ingress == 'disabled')) return [3 /*break*/, 15]; + _a.label = 17; + case 17: + if (!(this.ingress == 'disabled')) return [3 /*break*/, 19]; return [4 /*yield*/, this.appHelper.disableContainerAppIngress(this.containerAppName, this.resourceGroup)]; - case 14: + case 18: _a.sent(); - _a.label = 15; - case 15: return [2 /*return*/]; + _a.label = 19; + case 19: return [2 /*return*/]; } }); }); }; + azurecontainerapps.defaultRegistryServer = 'default/'; return azurecontainerapps; }()); exports.azurecontainerapps = azurecontainerapps; @@ -690,7 +709,7 @@ azurecontainerapps.runMain(); /***/ }), -/***/ 4052: +/***/ 5688: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -717,7 +736,7 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", ({ value: true })); exports.issue = exports.issueCommand = void 0; const os = __importStar(__nccwpck_require__(2037)); -const utils_1 = __nccwpck_require__(9549); +const utils_1 = __nccwpck_require__(869); /** * Commands * @@ -789,7 +808,7 @@ function escapeProperty(s) { /***/ }), -/***/ 5442: +/***/ 3195: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -824,12 +843,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0; -const command_1 = __nccwpck_require__(4052); -const file_command_1 = __nccwpck_require__(768); -const utils_1 = __nccwpck_require__(9549); +const command_1 = __nccwpck_require__(5688); +const file_command_1 = __nccwpck_require__(3930); +const utils_1 = __nccwpck_require__(869); const os = __importStar(__nccwpck_require__(2037)); const path = __importStar(__nccwpck_require__(1017)); -const oidc_utils_1 = __nccwpck_require__(4567); +const oidc_utils_1 = __nccwpck_require__(1755); /** * The code to exit an action */ @@ -1114,17 +1133,17 @@ exports.getIDToken = getIDToken; /** * Summary exports */ -var summary_1 = __nccwpck_require__(3991); +var summary_1 = __nccwpck_require__(8606); Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } })); /** * @deprecated use core.summary */ -var summary_2 = __nccwpck_require__(3991); +var summary_2 = __nccwpck_require__(8606); Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } })); /** * Path exports */ -var path_utils_1 = __nccwpck_require__(1096); +var path_utils_1 = __nccwpck_require__(397); Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } })); Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } })); Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } })); @@ -1132,7 +1151,7 @@ Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: funct /***/ }), -/***/ 768: +/***/ 3930: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -1163,8 +1182,8 @@ exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__nccwpck_require__(7147)); const os = __importStar(__nccwpck_require__(2037)); -const uuid_1 = __nccwpck_require__(4851); -const utils_1 = __nccwpck_require__(9549); +const uuid_1 = __nccwpck_require__(5814); +const utils_1 = __nccwpck_require__(869); function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { @@ -1197,7 +1216,7 @@ exports.prepareKeyValueMessage = prepareKeyValueMessage; /***/ }), -/***/ 4567: +/***/ 1755: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -1213,9 +1232,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.OidcClient = void 0; -const http_client_1 = __nccwpck_require__(3674); -const auth_1 = __nccwpck_require__(2598); -const core_1 = __nccwpck_require__(5442); +const http_client_1 = __nccwpck_require__(9780); +const auth_1 = __nccwpck_require__(8833); +const core_1 = __nccwpck_require__(3195); class OidcClient { static createHttpClient(allowRetry = true, maxRetry = 10) { const requestOptions = { @@ -1281,7 +1300,7 @@ exports.OidcClient = OidcClient; /***/ }), -/***/ 1096: +/***/ 397: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -1346,7 +1365,7 @@ exports.toPlatformPath = toPlatformPath; /***/ }), -/***/ 3991: +/***/ 8606: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -1636,7 +1655,7 @@ exports.summary = _summary; /***/ }), -/***/ 9549: +/***/ 869: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -1683,7 +1702,7 @@ exports.toCommandProperties = toCommandProperties; /***/ }), -/***/ 1935: +/***/ 9714: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -1719,7 +1738,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getExecOutput = exports.exec = void 0; const string_decoder_1 = __nccwpck_require__(1576); -const tr = __importStar(__nccwpck_require__(485)); +const tr = __importStar(__nccwpck_require__(5315)); /** * Exec a command. * Output will be streamed to the live console. @@ -1793,7 +1812,7 @@ exports.getExecOutput = getExecOutput; /***/ }), -/***/ 485: +/***/ 5315: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -1832,8 +1851,8 @@ const os = __importStar(__nccwpck_require__(2037)); const events = __importStar(__nccwpck_require__(2361)); const child = __importStar(__nccwpck_require__(2081)); const path = __importStar(__nccwpck_require__(1017)); -const io = __importStar(__nccwpck_require__(7597)); -const ioUtil = __importStar(__nccwpck_require__(3510)); +const io = __importStar(__nccwpck_require__(9529)); +const ioUtil = __importStar(__nccwpck_require__(7821)); const timers_1 = __nccwpck_require__(9512); /* eslint-disable @typescript-eslint/unbound-method */ const IS_WINDOWS = process.platform === 'win32'; @@ -2418,7 +2437,7 @@ class ExecState extends events.EventEmitter { /***/ }), -/***/ 2598: +/***/ 8833: /***/ (function(__unused_webpack_module, exports) { "use strict"; @@ -2506,7 +2525,7 @@ exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHand /***/ }), -/***/ 3674: +/***/ 9780: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -2544,8 +2563,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0; const http = __importStar(__nccwpck_require__(3685)); const https = __importStar(__nccwpck_require__(5687)); -const pm = __importStar(__nccwpck_require__(4913)); -const tunnel = __importStar(__nccwpck_require__(2493)); +const pm = __importStar(__nccwpck_require__(4492)); +const tunnel = __importStar(__nccwpck_require__(9041)); var HttpCodes; (function (HttpCodes) { HttpCodes[HttpCodes["OK"] = 200] = "OK"; @@ -3131,7 +3150,7 @@ const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCa /***/ }), -/***/ 4913: +/***/ 4492: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -3220,7 +3239,7 @@ function isLoopbackAddress(host) { /***/ }), -/***/ 3510: +/***/ 7821: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -3410,7 +3429,7 @@ exports.getCmdPath = getCmdPath; /***/ }), -/***/ 7597: +/***/ 9529: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -3447,7 +3466,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0; const assert_1 = __nccwpck_require__(9491); const path = __importStar(__nccwpck_require__(1017)); -const ioUtil = __importStar(__nccwpck_require__(3510)); +const ioUtil = __importStar(__nccwpck_require__(7821)); /** * Copies a file or folder. * Based off of shelljs - https://github.com/shelljs/shelljs/blob/9237f66c52e5daa40458f94f9565e18e8132f5a6/src/cp.js @@ -3716,15 +3735,15 @@ function copyFile(srcFile, destFile, force) { /***/ }), -/***/ 2493: +/***/ 9041: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -module.exports = __nccwpck_require__(4757); +module.exports = __nccwpck_require__(7111); /***/ }), -/***/ 4757: +/***/ 7111: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -3996,7 +4015,7 @@ exports.debug = debug; // for test /***/ }), -/***/ 4851: +/***/ 5814: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4060,29 +4079,29 @@ Object.defineProperty(exports, "parse", ({ } })); -var _v = _interopRequireDefault(__nccwpck_require__(9633)); +var _v = _interopRequireDefault(__nccwpck_require__(6471)); -var _v2 = _interopRequireDefault(__nccwpck_require__(8889)); +var _v2 = _interopRequireDefault(__nccwpck_require__(3384)); -var _v3 = _interopRequireDefault(__nccwpck_require__(9538)); +var _v3 = _interopRequireDefault(__nccwpck_require__(5940)); -var _v4 = _interopRequireDefault(__nccwpck_require__(3153)); +var _v4 = _interopRequireDefault(__nccwpck_require__(9193)); -var _nil = _interopRequireDefault(__nccwpck_require__(3500)); +var _nil = _interopRequireDefault(__nccwpck_require__(8654)); -var _version = _interopRequireDefault(__nccwpck_require__(5772)); +var _version = _interopRequireDefault(__nccwpck_require__(2362)); -var _validate = _interopRequireDefault(__nccwpck_require__(8311)); +var _validate = _interopRequireDefault(__nccwpck_require__(9815)); -var _stringify = _interopRequireDefault(__nccwpck_require__(1906)); +var _stringify = _interopRequireDefault(__nccwpck_require__(5183)); -var _parse = _interopRequireDefault(__nccwpck_require__(5521)); +var _parse = _interopRequireDefault(__nccwpck_require__(5108)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /***/ }), -/***/ 9972: +/***/ 9313: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4112,7 +4131,7 @@ exports["default"] = _default; /***/ }), -/***/ 3500: +/***/ 8654: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -4127,7 +4146,7 @@ exports["default"] = _default; /***/ }), -/***/ 5521: +/***/ 5108: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4138,7 +4157,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _validate = _interopRequireDefault(__nccwpck_require__(8311)); +var _validate = _interopRequireDefault(__nccwpck_require__(9815)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4179,7 +4198,7 @@ exports["default"] = _default; /***/ }), -/***/ 7735: +/***/ 1629: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -4194,7 +4213,7 @@ exports["default"] = _default; /***/ }), -/***/ 2864: +/***/ 9271: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4225,7 +4244,7 @@ function rng() { /***/ }), -/***/ 4209: +/***/ 2017: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4255,7 +4274,7 @@ exports["default"] = _default; /***/ }), -/***/ 1906: +/***/ 5183: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4266,7 +4285,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _validate = _interopRequireDefault(__nccwpck_require__(8311)); +var _validate = _interopRequireDefault(__nccwpck_require__(9815)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4301,7 +4320,7 @@ exports["default"] = _default; /***/ }), -/***/ 9633: +/***/ 6471: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4312,9 +4331,9 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _rng = _interopRequireDefault(__nccwpck_require__(2864)); +var _rng = _interopRequireDefault(__nccwpck_require__(9271)); -var _stringify = _interopRequireDefault(__nccwpck_require__(1906)); +var _stringify = _interopRequireDefault(__nccwpck_require__(5183)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4415,7 +4434,7 @@ exports["default"] = _default; /***/ }), -/***/ 8889: +/***/ 3384: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4426,9 +4445,9 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _v = _interopRequireDefault(__nccwpck_require__(1171)); +var _v = _interopRequireDefault(__nccwpck_require__(5717)); -var _md = _interopRequireDefault(__nccwpck_require__(9972)); +var _md = _interopRequireDefault(__nccwpck_require__(9313)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4438,7 +4457,7 @@ exports["default"] = _default; /***/ }), -/***/ 1171: +/***/ 5717: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4450,9 +4469,9 @@ Object.defineProperty(exports, "__esModule", ({ exports["default"] = _default; exports.URL = exports.DNS = void 0; -var _stringify = _interopRequireDefault(__nccwpck_require__(1906)); +var _stringify = _interopRequireDefault(__nccwpck_require__(5183)); -var _parse = _interopRequireDefault(__nccwpck_require__(5521)); +var _parse = _interopRequireDefault(__nccwpck_require__(5108)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4523,7 +4542,7 @@ function _default(name, version, hashfunc) { /***/ }), -/***/ 9538: +/***/ 5940: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4534,9 +4553,9 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _rng = _interopRequireDefault(__nccwpck_require__(2864)); +var _rng = _interopRequireDefault(__nccwpck_require__(9271)); -var _stringify = _interopRequireDefault(__nccwpck_require__(1906)); +var _stringify = _interopRequireDefault(__nccwpck_require__(5183)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4567,7 +4586,7 @@ exports["default"] = _default; /***/ }), -/***/ 3153: +/***/ 9193: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4578,9 +4597,9 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _v = _interopRequireDefault(__nccwpck_require__(1171)); +var _v = _interopRequireDefault(__nccwpck_require__(5717)); -var _sha = _interopRequireDefault(__nccwpck_require__(4209)); +var _sha = _interopRequireDefault(__nccwpck_require__(2017)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4590,7 +4609,7 @@ exports["default"] = _default; /***/ }), -/***/ 8311: +/***/ 9815: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4601,7 +4620,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _regex = _interopRequireDefault(__nccwpck_require__(7735)); +var _regex = _interopRequireDefault(__nccwpck_require__(1629)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4614,7 +4633,7 @@ exports["default"] = _default; /***/ }), -/***/ 5772: +/***/ 2362: /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4625,7 +4644,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _validate = _interopRequireDefault(__nccwpck_require__(8311)); +var _validate = _interopRequireDefault(__nccwpck_require__(9815)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4642,7 +4661,7 @@ exports["default"] = _default; /***/ }), -/***/ 1621: +/***/ 2929: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -4687,8 +4706,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.ContainerAppHelper = void 0; var path = __nccwpck_require__(1017); var os = __nccwpck_require__(2037); -var Utility_1 = __nccwpck_require__(5077); -var GitHubActionsToolHelper_1 = __nccwpck_require__(5119); +var Utility_1 = __nccwpck_require__(2135); +var GitHubActionsToolHelper_1 = __nccwpck_require__(3185); var fs = __nccwpck_require__(7147); var ORYX_CLI_IMAGE = 'mcr.microsoft.com/oryx/cli:builder-debian-bullseye-20230926.1'; var ORYX_BULLSEYE_BUILDER_IMAGE = 'mcr.microsoft.com/oryx/builder:debian-bullseye-20231025.1'; @@ -4704,24 +4723,23 @@ var ContainerAppHelper = /** @class */ (function () { this.disableTelemetry = disableTelemetry; } /** - * Creates an Azure Container App based from an image that was previously built. + * Creates an Azure Container App. * @param containerAppName - the name of the Container App * @param resourceGroup - the resource group that the Container App is found in * @param environment - the Container App Environment that will be associated with the Container App - * @param imageToDeploy - the name of the runnable application image that the Container App will be based from * @param optionalCmdArgs - a set of optional command line arguments */ - ContainerAppHelper.prototype.createContainerApp = function (containerAppName, resourceGroup, environment, imageToDeploy, optionalCmdArgs) { + ContainerAppHelper.prototype.createContainerApp = function (containerAppName, resourceGroup, environment, optionalCmdArgs) { return __awaiter(this, void 0, void 0, function () { var command_1, err_1; return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to create Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\" based from image \"").concat(imageToDeploy, "\"")); + toolHelper.writeDebug("Attempting to create Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\"")); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_1 = "az containerapp create -n ".concat(containerAppName, " -g ").concat(resourceGroup, " -i ").concat(imageToDeploy, " --environment ").concat(environment, " --output none"); + command_1 = "az containerapp create -n ".concat(containerAppName, " -g ").concat(resourceGroup, " --environment ").concat(environment, " --output none"); optionalCmdArgs.forEach(function (val) { command_1 += " ".concat(val); }); @@ -4738,6 +4756,40 @@ var ContainerAppHelper = /** @class */ (function () { }); }); }; + /** + * Creates an Azure Container App. + * @param containerAppName - the name of the Container App + * @param resourceGroup - the resource group that the Container App is found in + * @param environment - the Container App Environment that will be associated with the Container App + * @param optionalCmdArgs - a set of optional command line arguments + */ + ContainerAppHelper.prototype.createOrUpdateContainerAppWithUp = function (containerAppName, resourceGroup, environment, location, optionalCmdArgs) { + return __awaiter(this, void 0, void 0, function () { + var command_2, err_2; + return __generator(this, function (_a) { + switch (_a.label) { + case 0: + toolHelper.writeDebug("Attempting to create Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\"")); + _a.label = 1; + case 1: + _a.trys.push([1, 3, , 4]); + command_2 = "az containerapp up -n ".concat(containerAppName, " -g ").concat(resourceGroup, " --environment ").concat(environment, " -l northcentralusstage"); + optionalCmdArgs.forEach(function (val) { + command_2 += " ".concat(val); + }); + return [4 /*yield*/, util.execute(command_2)]; + case 2: + _a.sent(); + return [3 /*break*/, 4]; + case 3: + err_2 = _a.sent(); + toolHelper.writeError(err_2.message); + throw err_2; + case 4: return [2 /*return*/]; + } + }); + }); + }; /** * Creates an Azure Container App based from a YAML configuration file. * @param containerAppName - the name of the Container App @@ -4746,7 +4798,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.createContainerAppFromYaml = function (containerAppName, resourceGroup, yamlConfigPath) { return __awaiter(this, void 0, void 0, function () { - var command, err_2; + var command, err_3; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -4760,9 +4812,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_2 = _a.sent(); - toolHelper.writeError(err_2.message); - throw err_2; + err_3 = _a.sent(); + toolHelper.writeError(err_3.message); + throw err_3; case 4: return [2 /*return*/]; } }); @@ -4772,31 +4824,30 @@ var ContainerAppHelper = /** @class */ (function () { * Updates an existing Azure Container App based from an image that was previously built. * @param containerAppName - the name of the existing Container App * @param resourceGroup - the resource group that the existing Container App is found in - * @param imageToDeploy - the name of the runnable application image that the Container App will be based from * @param optionalCmdArgs - a set of optional command line arguments */ - ContainerAppHelper.prototype.updateContainerApp = function (containerAppName, resourceGroup, imageToDeploy, optionalCmdArgs) { + ContainerAppHelper.prototype.updateContainerApp = function (containerAppName, resourceGroup, optionalCmdArgs) { return __awaiter(this, void 0, void 0, function () { - var command_2, err_3; + var command_3, err_4; return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to update Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\" based from image \"").concat(imageToDeploy, "\"")); + toolHelper.writeDebug("Attempting to update Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\" ")); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_2 = "az containerapp update -n ".concat(containerAppName, " -g ").concat(resourceGroup, " -i ").concat(imageToDeploy, " --output none"); + command_3 = "az containerapp update -n ".concat(containerAppName, " -g ").concat(resourceGroup, " --output none"); optionalCmdArgs.forEach(function (val) { - command_2 += " ".concat(val); + command_3 += " ".concat(val); }); - return [4 /*yield*/, util.execute(command_2)]; + return [4 /*yield*/, util.execute(command_3)]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: - err_3 = _a.sent(); - toolHelper.writeError(err_3.message); - throw err_3; + err_4 = _a.sent(); + toolHelper.writeError(err_4.message); + throw err_4; case 4: return [2 /*return*/]; } }); @@ -4806,39 +4857,38 @@ var ContainerAppHelper = /** @class */ (function () { * Updates an existing Azure Container App using the 'az containerapp up' command. * @param containerAppName - the name of the existing Container App * @param resourceGroup - the resource group that the existing Container App is found in - * @param imageToDeploy - the name of the runnable application image that the Container App will be based from * @param optionalCmdArgs - a set of optional command line arguments * @param ingress - the ingress that the Container App will be exposed on * @param targetPort - the target port that the Container App will be exposed on */ - ContainerAppHelper.prototype.updateContainerAppWithUp = function (containerAppName, resourceGroup, imageToDeploy, optionalCmdArgs, ingress, targetPort) { + ContainerAppHelper.prototype.updateContainerAppWithUp = function (containerAppName, resourceGroup, optionalCmdArgs, ingress, targetPort) { return __awaiter(this, void 0, void 0, function () { - var command_3, err_4; + var command_4, err_5; return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to update Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\" based from image \"").concat(imageToDeploy, "\"")); + toolHelper.writeDebug("Attempting to update Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\"")); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_3 = "az containerapp up -n ".concat(containerAppName, " -g ").concat(resourceGroup, " -i ").concat(imageToDeploy); + command_4 = "az containerapp up -n ".concat(containerAppName, " -g ").concat(resourceGroup); optionalCmdArgs.forEach(function (val) { - command_3 += " ".concat(val); + command_4 += " ".concat(val); }); if (!util.isNullOrEmpty(ingress)) { - command_3 += " --ingress ".concat(ingress); + command_4 += " --ingress ".concat(ingress); } if (!util.isNullOrEmpty(targetPort)) { - command_3 += " --target-port ".concat(targetPort); + command_4 += " --target-port ".concat(targetPort); } - return [4 /*yield*/, util.execute(command_3)]; + return [4 /*yield*/, util.execute(command_4)]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: - err_4 = _a.sent(); - toolHelper.writeError(err_4.message); - throw err_4; + err_5 = _a.sent(); + toolHelper.writeError(err_5.message); + throw err_5; case 4: return [2 /*return*/]; } }); @@ -4852,7 +4902,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.updateContainerAppFromYaml = function (containerAppName, resourceGroup, yamlConfigPath) { return __awaiter(this, void 0, void 0, function () { - var command, err_5; + var command, err_6; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -4866,9 +4916,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_5 = _a.sent(); - toolHelper.writeError(err_5.message); - throw err_5; + err_6 = _a.sent(); + toolHelper.writeError(err_6.message); + throw err_6; case 4: return [2 /*return*/]; } }); @@ -4882,7 +4932,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.doesContainerAppExist = function (containerAppName, resourceGroup) { return __awaiter(this, void 0, void 0, function () { - var command, executionResult, err_6; + var command, executionResult, err_7; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -4896,8 +4946,8 @@ var ContainerAppHelper = /** @class */ (function () { executionResult = _a.sent(); return [2 /*return*/, executionResult.exitCode === 0]; case 3: - err_6 = _a.sent(); - toolHelper.writeInfo(err_6.message); + err_7 = _a.sent(); + toolHelper.writeInfo(err_7.message); return [2 /*return*/, false]; case 4: return [2 /*return*/]; } @@ -4912,7 +4962,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.doesContainerAppEnvironmentExist = function (containerAppEnvironment, resourceGroup) { return __awaiter(this, void 0, void 0, function () { - var command, executionResult, err_7; + var command, executionResult, err_8; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -4926,8 +4976,8 @@ var ContainerAppHelper = /** @class */ (function () { executionResult = _a.sent(); return [2 /*return*/, executionResult.exitCode === 0]; case 3: - err_7 = _a.sent(); - toolHelper.writeInfo(err_7.message); + err_8 = _a.sent(); + toolHelper.writeInfo(err_8.message); return [2 /*return*/, false]; case 4: return [2 /*return*/]; } @@ -4941,7 +4991,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.doesResourceGroupExist = function (resourceGroup) { return __awaiter(this, void 0, void 0, function () { - var command, executionResult, err_8; + var command, executionResult, err_9; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -4955,8 +5005,8 @@ var ContainerAppHelper = /** @class */ (function () { executionResult = _a.sent(); return [2 /*return*/, executionResult.exitCode === 0]; case 3: - err_8 = _a.sent(); - toolHelper.writeInfo(err_8.message); + err_9 = _a.sent(); + toolHelper.writeInfo(err_9.message); return [2 /*return*/, false]; case 4: return [2 /*return*/]; } @@ -4969,7 +5019,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.getDefaultContainerAppLocation = function () { return __awaiter(this, void 0, void 0, function () { - var command, executionResult, err_9; + var command, executionResult, err_10; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -4984,8 +5034,8 @@ var ContainerAppHelper = /** @class */ (function () { // If successful, strip out double quotes, spaces and parentheses from the first location returned return [2 /*return*/, executionResult.exitCode === 0 ? executionResult.stdout.toLowerCase().replace(/["() ]/g, "").trim() : "eastus2"]; case 3: - err_9 = _a.sent(); - toolHelper.writeInfo(err_9.message); + err_10 = _a.sent(); + toolHelper.writeInfo(err_10.message); return [2 /*return*/, "eastus2"]; case 4: return [2 /*return*/]; } @@ -4999,7 +5049,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.createResourceGroup = function (name, location) { return __awaiter(this, void 0, void 0, function () { - var command, err_10; + var command, err_11; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5013,9 +5063,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_10 = _a.sent(); - toolHelper.writeError(err_10.message); - throw err_10; + err_11 = _a.sent(); + toolHelper.writeError(err_11.message); + throw err_11; case 4: return [2 /*return*/]; } }); @@ -5028,7 +5078,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.getExistingContainerAppEnvironment = function (resourceGroup) { return __awaiter(this, void 0, void 0, function () { - var command, executionResult, err_11; + var command, executionResult, err_12; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5042,8 +5092,8 @@ var ContainerAppHelper = /** @class */ (function () { executionResult = _a.sent(); return [2 /*return*/, executionResult.exitCode === 0 ? executionResult.stdout : null]; case 3: - err_11 = _a.sent(); - toolHelper.writeInfo(err_11.message); + err_12 = _a.sent(); + toolHelper.writeInfo(err_12.message); return [2 /*return*/, null]; case 4: return [2 /*return*/]; } @@ -5058,7 +5108,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.createContainerAppEnvironment = function (name, resourceGroup, location) { return __awaiter(this, void 0, void 0, function () { - var util, command, err_12; + var util, command, err_13; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5076,9 +5126,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_12 = _a.sent(); - toolHelper.writeError(err_12.message); - throw err_12; + err_13 = _a.sent(); + toolHelper.writeError(err_13.message); + throw err_13; case 4: return [2 /*return*/]; } }); @@ -5091,7 +5141,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.disableContainerAppIngress = function (name, resourceGroup) { return __awaiter(this, void 0, void 0, function () { - var command, err_13; + var command, err_14; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5105,9 +5155,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_13 = _a.sent(); - toolHelper.writeError(err_13.message); - throw err_13; + err_14 = _a.sent(); + toolHelper.writeError(err_14.message); + throw err_14; case 4: return [2 /*return*/]; } }); @@ -5123,7 +5173,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.updateContainerAppRegistryDetails = function (name, resourceGroup, registryUrl, registryUsername, registryPassword) { return __awaiter(this, void 0, void 0, function () { - var command, err_14; + var command, err_15; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5137,9 +5187,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_14 = _a.sent(); - toolHelper.writeError(err_14.message); - throw err_14; + err_15 = _a.sent(); + toolHelper.writeError(err_15.message); + throw err_15; case 4: return [2 /*return*/]; } }); @@ -5164,7 +5214,7 @@ var ContainerAppHelper = /** @class */ (function () { } couldBuildImage = false; _loop_1 = function (builderImage) { - var command_4, err_15; + var command_5, err_16; return __generator(this, function (_b) { switch (_b.label) { case 0: @@ -5175,18 +5225,18 @@ var ContainerAppHelper = /** @class */ (function () { _b.label = 1; case 1: _b.trys.push([1, 3, , 4]); - command_4 = "build ".concat(imageToDeploy, " --path ").concat(appSourcePath, " --builder ").concat(builderImage, " --env ").concat(telemetryArg); + command_5 = "build ".concat(imageToDeploy, " --path ").concat(appSourcePath, " --builder ").concat(builderImage, " --env ").concat(telemetryArg); environmentVariables.forEach(function (envVar) { - command_4 += " --env ".concat(envVar); + command_5 += " --env ".concat(envVar); }); - return [4 /*yield*/, util.execute("".concat(PACK_CMD, " ").concat(command_4))]; + return [4 /*yield*/, util.execute("".concat(PACK_CMD, " ").concat(command_5))]; case 2: _b.sent(); couldBuildImage = true; return [2 /*return*/, "break"]; case 3: - err_15 = _b.sent(); - toolHelper.writeWarning("Unable to run 'pack build' command to produce runnable application image: ".concat(err_15.message)); + err_16 = _b.sent(); + toolHelper.writeWarning("Unable to run 'pack build' command to produce runnable application image: ".concat(err_16.message)); return [3 /*break*/, 4]; case 4: return [2 /*return*/]; } @@ -5226,9 +5276,9 @@ var ContainerAppHelper = /** @class */ (function () { * @param appSourcePath - the path to the application source on the machine * @param dockerfilePath - the path to the Dockerfile to build and tag with the provided image name */ - ContainerAppHelper.prototype.createRunnableAppImageFromDockerfile = function (imageToDeploy, appSourcePath, dockerfilePath, buildArguments) { + ContainerAppHelper.prototype.createRunnableAppImageFromDockerfile = function (imageToDeploy, appSourcePath, dockerfilePath) { return __awaiter(this, void 0, void 0, function () { - var command_5, err_16; + var command, err_17; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5236,22 +5286,16 @@ var ContainerAppHelper = /** @class */ (function () { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_5 = "docker build --file ".concat(dockerfilePath, " ").concat(appSourcePath, " --tag ").concat(imageToDeploy); - // If build arguments were provided, append them to the command - if (buildArguments.length > 0) { - buildArguments.forEach(function (buildArg) { - command_5 += " --build-arg ".concat(buildArg); - }); - } - return [4 /*yield*/, util.execute(command_5)]; + command = "docker build --file ".concat(dockerfilePath, " ").concat(appSourcePath, " --tag ").concat(imageToDeploy); + return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); toolHelper.writeDebug("Successfully created runnable application image from the provided/found Dockerfile \"".concat(dockerfilePath, "\" with image name \"").concat(imageToDeploy, "\"")); return [3 /*break*/, 4]; case 3: - err_16 = _a.sent(); - toolHelper.writeError(err_16.message); - throw err_16; + err_17 = _a.sent(); + toolHelper.writeError(err_17.message); + throw err_17; case 4: return [2 /*return*/]; } }); @@ -5264,7 +5308,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.determineRuntimeStackAsync = function (appSourcePath) { return __awaiter(this, void 0, void 0, function () { - var command, oryxRuntimeTxtPath_1, runtimeStack, err_17; + var command, oryxRuntimeTxtPath_1, runtimeStack, err_18; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5294,9 +5338,9 @@ var ContainerAppHelper = /** @class */ (function () { }); return [2 /*return*/, runtimeStack]; case 3: - err_17 = _a.sent(); - toolHelper.writeError(err_17.message); - throw err_17; + err_18 = _a.sent(); + toolHelper.writeError(err_18.message); + throw err_18; case 4: return [2 /*return*/]; } }); @@ -5308,7 +5352,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.setDefaultBuilder = function () { return __awaiter(this, void 0, void 0, function () { - var command, err_18; + var command, err_19; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5322,9 +5366,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_18 = _a.sent(); - toolHelper.writeError(err_18.message); - throw err_18; + err_19 = _a.sent(); + toolHelper.writeError(err_19.message); + throw err_19; case 4: return [2 /*return*/]; } }); @@ -5336,7 +5380,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.installPackCliAsync = function () { return __awaiter(this, void 0, void 0, function () { - var command, commandLine, packZipDownloadUri, packZipDownloadFilePath, tgzSuffix, err_19; + var command, commandLine, packZipDownloadUri, packZipDownloadFilePath, tgzSuffix, err_20; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5363,9 +5407,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_19 = _a.sent(); - toolHelper.writeError("Unable to install the pack CLI. Error: ".concat(err_19.message)); - throw err_19; + err_20 = _a.sent(); + toolHelper.writeError("Unable to install the pack CLI. Error: ".concat(err_20.message)); + throw err_20; case 4: return [2 /*return*/]; } }); @@ -5376,7 +5420,7 @@ var ContainerAppHelper = /** @class */ (function () { */ ContainerAppHelper.prototype.enablePackCliExperimentalFeaturesAsync = function () { return __awaiter(this, void 0, void 0, function () { - var command, err_20; + var command, err_21; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -5390,9 +5434,9 @@ var ContainerAppHelper = /** @class */ (function () { _a.sent(); return [3 /*break*/, 4]; case 3: - err_20 = _a.sent(); - toolHelper.writeError("Unable to enable experimental features for the pack CLI: ".concat(err_20.message)); - throw err_20; + err_21 = _a.sent(); + toolHelper.writeError("Unable to enable experimental features for the pack CLI: ".concat(err_21.message)); + throw err_21; case 4: return [2 /*return*/]; } }); @@ -5405,7 +5449,7 @@ exports.ContainerAppHelper = ContainerAppHelper; /***/ }), -/***/ 2673: +/***/ 4769: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -5449,8 +5493,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) { Object.defineProperty(exports, "__esModule", ({ value: true })); exports.ContainerRegistryHelper = void 0; var os = __nccwpck_require__(2037); -var Utility_1 = __nccwpck_require__(5077); -var GitHubActionsToolHelper_1 = __nccwpck_require__(5119); +var Utility_1 = __nccwpck_require__(2135); +var GitHubActionsToolHelper_1 = __nccwpck_require__(3185); var toolHelper = new GitHubActionsToolHelper_1.GitHubActionsToolHelper(); var util = new Utility_1.Utility(); var ContainerRegistryHelper = /** @class */ (function () { @@ -5548,7 +5592,7 @@ exports.ContainerRegistryHelper = ContainerRegistryHelper; /***/ }), -/***/ 5119: +/***/ 3185: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -5591,9 +5635,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.GitHubActionsToolHelper = void 0; -var core = __nccwpck_require__(5442); -var io = __nccwpck_require__(7597); -var exec = __nccwpck_require__(1935); +var core = __nccwpck_require__(3195); +var io = __nccwpck_require__(9529); +var exec = __nccwpck_require__(9714); var GitHubActionsToolHelper = /** @class */ (function () { function GitHubActionsToolHelper() { } @@ -5689,7 +5733,7 @@ exports.GitHubActionsToolHelper = GitHubActionsToolHelper; /***/ }), -/***/ 7893: +/***/ 7166: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -5732,8 +5776,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) { }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.TelemetryHelper = void 0; -var Utility_1 = __nccwpck_require__(5077); -var GitHubActionsToolHelper_1 = __nccwpck_require__(5119); +var Utility_1 = __nccwpck_require__(2135); +var GitHubActionsToolHelper_1 = __nccwpck_require__(3185); var ORYX_CLI_IMAGE = "mcr.microsoft.com/oryx/cli:debian-buster-20230207.2"; var SUCCESSFUL_RESULT = "succeeded"; var FAILED_RESULT = "failed"; @@ -5826,7 +5870,7 @@ exports.TelemetryHelper = TelemetryHelper; /***/ }), -/***/ 5077: +/***/ 2135: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -5870,7 +5914,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { Object.defineProperty(exports, "__esModule", ({ value: true })); exports.Utility = void 0; // Note: This file is used to define utility functions that can be used across the project. -var GitHubActionsToolHelper_1 = __nccwpck_require__(5119); +var GitHubActionsToolHelper_1 = __nccwpck_require__(3185); var toolHelper = new GitHubActionsToolHelper_1.GitHubActionsToolHelper(); var Utility = /** @class */ (function () { function Utility() { @@ -5891,14 +5935,13 @@ var Utility = /** @class */ (function () { }); }; /** - * Sets the Azure CLI to dynamically install extensions that are missing. In this case, we care about the - * Azure Container Apps module being dynamically installed while it's still in preview. + * Sets the Azure CLI to dynamically install extensions that are missing. */ Utility.prototype.setAzureCliDynamicInstall = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, this.execute("az config set extension.use_dynamic_install=yes_without_prompt")]; + case 0: return [4 /*yield*/, this.execute("az extension add --name containerapp --upgrade")]; case 1: _a.sent(); return [2 /*return*/]; @@ -6075,7 +6118,7 @@ module.exports = require("util"); /******/ // startup /******/ // Load entry module and return exports /******/ // This entry module is referenced by other modules so it can't be inlined -/******/ var __webpack_exports__ = __nccwpck_require__(7595); +/******/ var __webpack_exports__ = __nccwpck_require__(3238); /******/ module.exports = __webpack_exports__; /******/ /******/ })() diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index 86d4c5f3..630b2b77 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -21,22 +21,46 @@ export class ContainerAppHelper { } /** - * Creates an Azure Container App based from an image that was previously built. + * Creates an Azure Container App. * @param containerAppName - the name of the Container App * @param resourceGroup - the resource group that the Container App is found in * @param environment - the Container App Environment that will be associated with the Container App - * @param imageToDeploy - the name of the runnable application image that the Container App will be based from * @param optionalCmdArgs - a set of optional command line arguments */ public async createContainerApp( containerAppName: string, resourceGroup: string, environment: string, - imageToDeploy: string, optionalCmdArgs: string[]) { - toolHelper.writeDebug(`Attempting to create Container App with name "${containerAppName}" in resource group "${resourceGroup}" based from image "${imageToDeploy}"`); + toolHelper.writeDebug(`Attempting to create Container App with name "${containerAppName}" in resource group "${resourceGroup}"`); + try { + let command = `az containerapp create -n ${containerAppName} -g ${resourceGroup} --environment ${environment} --output none`; + optionalCmdArgs.forEach(function (val: string) { + command += ` ${val}`; + }); + await util.execute(command); + } catch (err) { + toolHelper.writeError(err.message); + throw err; + } + } + + /** + * Creates an Azure Container App. + * @param containerAppName - the name of the Container App + * @param resourceGroup - the resource group that the Container App is found in + * @param environment - the Container App Environment that will be associated with the Container App + * @param optionalCmdArgs - a set of optional command line arguments + */ + public async createOrUpdateContainerAppWithUp( + containerAppName: string, + resourceGroup: string, + environment: string, + location: string, + optionalCmdArgs: string[]) { + toolHelper.writeDebug(`Attempting to create Container App with name "${containerAppName}" in resource group "${resourceGroup}"`); try { - let command = `az containerapp create -n ${containerAppName} -g ${resourceGroup} -i ${imageToDeploy} --environment ${environment} --output none`; + let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} --environment ${environment} -l northcentralusstage`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); @@ -71,17 +95,15 @@ export class ContainerAppHelper { * Updates an existing Azure Container App based from an image that was previously built. * @param containerAppName - the name of the existing Container App * @param resourceGroup - the resource group that the existing Container App is found in - * @param imageToDeploy - the name of the runnable application image that the Container App will be based from * @param optionalCmdArgs - a set of optional command line arguments */ public async updateContainerApp( containerAppName: string, resourceGroup: string, - imageToDeploy: string, optionalCmdArgs: string[]) { - toolHelper.writeDebug(`Attempting to update Container App with name "${containerAppName}" in resource group "${resourceGroup}" based from image "${imageToDeploy}"`); + toolHelper.writeDebug(`Attempting to update Container App with name "${containerAppName}" in resource group "${resourceGroup}" `); try { - let command = `az containerapp update -n ${containerAppName} -g ${resourceGroup} -i ${imageToDeploy} --output none`; + let command = `az containerapp update -n ${containerAppName} -g ${resourceGroup} --output none`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); @@ -96,7 +118,6 @@ export class ContainerAppHelper { * Updates an existing Azure Container App using the 'az containerapp up' command. * @param containerAppName - the name of the existing Container App * @param resourceGroup - the resource group that the existing Container App is found in - * @param imageToDeploy - the name of the runnable application image that the Container App will be based from * @param optionalCmdArgs - a set of optional command line arguments * @param ingress - the ingress that the Container App will be exposed on * @param targetPort - the target port that the Container App will be exposed on @@ -104,13 +125,12 @@ export class ContainerAppHelper { public async updateContainerAppWithUp( containerAppName: string, resourceGroup: string, - imageToDeploy: string, optionalCmdArgs: string[], ingress?: string, targetPort?: string) { - toolHelper.writeDebug(`Attempting to update Container App with name "${containerAppName}" in resource group "${resourceGroup}" based from image "${imageToDeploy}"`); + toolHelper.writeDebug(`Attempting to update Container App with name "${containerAppName}" in resource group "${resourceGroup}"`); try { - let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} -i ${imageToDeploy}`; + let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup}`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); @@ -122,6 +142,7 @@ export class ContainerAppHelper { if (!util.isNullOrEmpty(targetPort)) { command += ` --target-port ${targetPort}`; } + await util.execute(command); } catch (err) { toolHelper.writeError(err.message); @@ -367,19 +388,10 @@ export class ContainerAppHelper { public async createRunnableAppImageFromDockerfile( imageToDeploy: string, appSourcePath: string, - dockerfilePath: string, - buildArguments: string[]) { + dockerfilePath: string) { toolHelper.writeDebug(`Attempting to create a runnable application image from the provided/found Dockerfile "${dockerfilePath}" with image name "${imageToDeploy}"`); try { let command = `docker build --file ${dockerfilePath} ${appSourcePath} --tag ${imageToDeploy}`; - - // If build arguments were provided, append them to the command - if (buildArguments.length > 0) { - buildArguments.forEach(function (buildArg: string) { - command += ` --build-arg ${buildArg}`; - }); - } - await util.execute(command); toolHelper.writeDebug(`Successfully created runnable application image from the provided/found Dockerfile "${dockerfilePath}" with image name "${imageToDeploy}"`); } catch (err) { diff --git a/src/Utility.ts b/src/Utility.ts index 6c55c9b6..e8391aaf 100644 --- a/src/Utility.ts +++ b/src/Utility.ts @@ -15,11 +15,10 @@ export class Utility { } /** - * Sets the Azure CLI to dynamically install extensions that are missing. In this case, we care about the - * Azure Container Apps module being dynamically installed while it's still in preview. + * Sets the Azure CLI to dynamically install extensions that are missing. */ public async setAzureCliDynamicInstall() { - await this.execute(`az config set extension.use_dynamic_install=yes_without_prompt`); + await this.execute(`az extension add --name containerapp --upgrade`); } /** From 0742a90fc2f38208a7c3f4776a737e698f0c0d54 Mon Sep 17 00:00:00 2001 From: snehapar9 <108305436+snehapar9@users.noreply.github.com> Date: Tue, 7 Nov 2023 11:54:20 -0800 Subject: [PATCH 02/12] Remove env as a required arg (#72) * Remove env as a required arg * Add index.js * Address PR comments * Remove env param --- .github/workflows/run-validation.yml | 2 -- azurecontainerapps.ts | 4 ++-- dist/index.js | 9 ++++----- src/ContainerAppHelper.ts | 5 +---- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/workflows/run-validation.yml b/.github/workflows/run-validation.yml index d7a964aa..a6d1e0a7 100644 --- a/.github/workflows/run-validation.yml +++ b/.github/workflows/run-validation.yml @@ -89,7 +89,6 @@ jobs: with: appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} - containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NO_ACR_NAME }} disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} @@ -464,7 +463,6 @@ jobs: with: appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' containerAppName: ${{ env.TEST_EXISTING_CONTAINER_APP }} - containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NO_ACR_NAME }} disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index 9110f738..c55e2947 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -557,7 +557,7 @@ export class azurecontainerapps { // Create the Container App from the YAML configuration file await this.appHelper.createContainerAppFromYaml(this.containerAppName, this.resourceGroup, this.yamlConfigPath); } else if (createOrUpdateContainerAppWithUp) { - await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs); + await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs); } else { // Create the Container App from command line arguments await this.appHelper.createContainerApp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.commandLineArgs); @@ -582,7 +582,7 @@ export class azurecontainerapps { // Update the Container App using the 'update' command await this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.commandLineArgs); } else if (createOrUpdateContainerAppWithUp) { - await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs); + await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs); } else { // Update the Container App using the 'up' command await this.appHelper.updateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs, this.ingress, this.targetPort); diff --git a/dist/index.js b/dist/index.js index 26ee397f..aac835a4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -642,7 +642,7 @@ var azurecontainerapps = /** @class */ (function () { return [3 /*break*/, 6]; case 2: if (!createOrUpdateContainerAppWithUp) return [3 /*break*/, 4]; - return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs)]; + return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs)]; case 3: _a.sent(); return [3 /*break*/, 6]; @@ -678,7 +678,7 @@ var azurecontainerapps = /** @class */ (function () { return [3 /*break*/, 17]; case 13: if (!createOrUpdateContainerAppWithUp) return [3 /*break*/, 15]; - return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.containerAppEnvironment, this.location, this.commandLineArgs)]; + return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs)]; case 14: _a.sent(); return [3 /*break*/, 17]; @@ -4760,10 +4760,9 @@ var ContainerAppHelper = /** @class */ (function () { * Creates an Azure Container App. * @param containerAppName - the name of the Container App * @param resourceGroup - the resource group that the Container App is found in - * @param environment - the Container App Environment that will be associated with the Container App * @param optionalCmdArgs - a set of optional command line arguments */ - ContainerAppHelper.prototype.createOrUpdateContainerAppWithUp = function (containerAppName, resourceGroup, environment, location, optionalCmdArgs) { + ContainerAppHelper.prototype.createOrUpdateContainerAppWithUp = function (containerAppName, resourceGroup, optionalCmdArgs) { return __awaiter(this, void 0, void 0, function () { var command_2, err_2; return __generator(this, function (_a) { @@ -4773,7 +4772,7 @@ var ContainerAppHelper = /** @class */ (function () { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_2 = "az containerapp up -n ".concat(containerAppName, " -g ").concat(resourceGroup, " --environment ").concat(environment, " -l northcentralusstage"); + command_2 = "az containerapp up -n ".concat(containerAppName, " -g ").concat(resourceGroup, " -l northcentralusstage"); optionalCmdArgs.forEach(function (val) { command_2 += " ".concat(val); }); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index 630b2b77..9a2a51c3 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -49,18 +49,15 @@ export class ContainerAppHelper { * Creates an Azure Container App. * @param containerAppName - the name of the Container App * @param resourceGroup - the resource group that the Container App is found in - * @param environment - the Container App Environment that will be associated with the Container App * @param optionalCmdArgs - a set of optional command line arguments */ public async createOrUpdateContainerAppWithUp( containerAppName: string, resourceGroup: string, - environment: string, - location: string, optionalCmdArgs: string[]) { toolHelper.writeDebug(`Attempting to create Container App with name "${containerAppName}" in resource group "${resourceGroup}"`); try { - let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} --environment ${environment} -l northcentralusstage`; + let command = `az containerapp up -n ${containerAppName} -g ${resourceGroup} -l northcentralusstage`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); From 39907e2bfb192a2ddc35f9f2b28d0156902b34e6 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Wed, 8 Nov 2023 13:53:00 -0800 Subject: [PATCH 03/12] Snap to containerapp version 0.3.43 --- dist/index.js | 232 ++++++++++++++++++++++++------------------------- src/Utility.ts | 2 +- 2 files changed, 117 insertions(+), 117 deletions(-) diff --git a/dist/index.js b/dist/index.js index aac835a4..02557d1f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -21,7 +21,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -42,7 +42,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.__esModule = true; exports.azurecontainerapps = void 0; var fs = __nccwpck_require__(7147); var path = __nccwpck_require__(1017); @@ -297,8 +297,8 @@ var azurecontainerapps = /** @class */ (function () { case 0: resourceGroup = this.toolHelper.getInput('resourceGroup', false); if (!this.util.isNullOrEmpty(resourceGroup)) return [3 /*break*/, 3]; - resourceGroup = "".concat(containerAppName, "-rg"); - this.toolHelper.writeInfo("Default resource group name: ".concat(resourceGroup)); + resourceGroup = containerAppName + "-rg"; + this.toolHelper.writeInfo("Default resource group name: " + resourceGroup); return [4 /*yield*/, this.appHelper.doesResourceGroupExist(resourceGroup)]; case 1: resourceGroupExists = _a.sent(); @@ -334,15 +334,15 @@ var azurecontainerapps = /** @class */ (function () { case 1: existingContainerAppEnvironment = _a.sent(); if (!this.util.isNullOrEmpty(existingContainerAppEnvironment)) { - this.toolHelper.writeInfo("Existing Container App environment found in resource group: ".concat(existingContainerAppEnvironment)); + this.toolHelper.writeInfo("Existing Container App environment found in resource group: " + existingContainerAppEnvironment); return [2 /*return*/, existingContainerAppEnvironment]; } _a.label = 2; case 2: // Generate the Container App environment name if it was not provided if (this.util.isNullOrEmpty(containerAppEnvironment)) { - containerAppEnvironment = "".concat(containerAppName, "-env"); - this.toolHelper.writeInfo("Default Container App environment name: ".concat(containerAppEnvironment)); + containerAppEnvironment = containerAppName + "-env"; + this.toolHelper.writeInfo("Default Container App environment name: " + containerAppEnvironment); } return [4 /*yield*/, this.appHelper.doesContainerAppEnvironmentExist(containerAppEnvironment, resourceGroup)]; case 3: @@ -367,15 +367,15 @@ var azurecontainerapps = /** @class */ (function () { case 0: this.registryUsername = this.toolHelper.getInput('acrUsername', false); this.registryPassword = this.toolHelper.getInput('acrPassword', false); - this.registryUrl = "".concat(this.acrName, ".azurecr.io"); + this.registryUrl = this.acrName + ".azurecr.io"; if (!(!this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword))) return [3 /*break*/, 2]; - this.toolHelper.writeInfo("Logging in to ACR instance \"".concat(this.acrName, "\" with username and password credentials")); + this.toolHelper.writeInfo("Logging in to ACR instance \"" + this.acrName + "\" with username and password credentials"); return [4 /*yield*/, this.registryHelper.loginContainerRegistryWithUsernamePassword(this.registryUrl, this.registryUsername, this.registryPassword)]; case 1: _a.sent(); return [3 /*break*/, 4]; case 2: - this.toolHelper.writeInfo("No ACR credentials provided; attempting to log in to ACR instance \"".concat(this.acrName, "\" with access token")); + this.toolHelper.writeInfo("No ACR credentials provided; attempting to log in to ACR instance \"" + this.acrName + "\" with access token"); return [4 /*yield*/, this.registryHelper.loginAcrWithAccessTokenAsync(this.acrName)]; case 3: _a.sent(); @@ -396,7 +396,7 @@ var azurecontainerapps = /** @class */ (function () { this.registryUsername = this.toolHelper.getInput('registryUsername', false); this.registryPassword = this.toolHelper.getInput('registryPassword', false); if (!(!this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword))) return [3 /*break*/, 2]; - this.toolHelper.writeInfo("Logging in to Container Registry \"".concat(this.registryUrl, "\" with username and password credentials")); + this.toolHelper.writeInfo("Logging in to Container Registry \"" + this.registryUrl + "\" with username and password credentials"); return [4 /*yield*/, this.registryHelper.loginContainerRegistryWithUsernamePassword(this.registryUrl, this.registryUsername, this.registryPassword)]; case 1: _a.sent(); @@ -423,13 +423,13 @@ var azurecontainerapps = /** @class */ (function () { var imageRepository = this.toolHelper.getDefaultImageRepository(); // Constructs the image to build based on the provided registry URL, image repository, build ID, and build number. // If the registry URL is not provided or is empty, the default registry server is used; otherwise, the provided registry URL is used. - this.imageToBuild = this.util.isNullOrEmpty(this.registryUrl) ? "".concat(this.defaultRegistryServer).concat(imageRepository, ":").concat(this.buildId, ".").concat(this.buildNumber) : "".concat(this.registryUrl, "/").concat(imageRepository, ":").concat(this.buildId, ".").concat(this.buildNumber); - this.toolHelper.writeInfo("Default image to build: ".concat(this.imageToBuild)); + this.imageToBuild = this.util.isNullOrEmpty(this.registryUrl) ? "" + this.defaultRegistryServer + imageRepository + ":" + this.buildId + "." + this.buildNumber : this.registryUrl + "/" + imageRepository + ":" + this.buildId + "." + this.buildNumber; + this.toolHelper.writeInfo("Default image to build: " + this.imageToBuild); } // Get the name of the image to deploy if it was provided, or set it to the value of 'imageToBuild' if (this.util.isNullOrEmpty(this.imageToDeploy)) { this.imageToDeploy = this.imageToBuild; - this.toolHelper.writeInfo("Default image to deploy: ".concat(this.imageToDeploy)); + this.toolHelper.writeInfo("Default image to deploy: " + this.imageToDeploy); } }; /** @@ -508,15 +508,15 @@ var azurecontainerapps = /** @class */ (function () { runtimeStackSplit = runtimeStack.split(':'); platformName = runtimeStackSplit[0] == "dotnetcore" ? "dotnet" : runtimeStackSplit[0]; platformVersion = runtimeStackSplit[1]; - environmentVariables.push("ORYX_PLATFORM_NAME=".concat(platformName)); - environmentVariables.push("ORYX_PLATFORM_VERSION=".concat(platformVersion)); + environmentVariables.push("ORYX_PLATFORM_NAME=" + platformName); + environmentVariables.push("ORYX_PLATFORM_VERSION=" + platformVersion); } builderStack = this.toolHelper.getInput('builderStack', false); // Set the target port on the image produced by the builder if (!this.util.isNullOrEmpty(this.targetPort)) { - environmentVariables.push("ORYX_RUNTIME_PORT=".concat(this.targetPort)); + environmentVariables.push("ORYX_RUNTIME_PORT=" + this.targetPort); } - this.toolHelper.writeInfo("Building image \"".concat(imageToBuild, "\" using the Oryx++ Builder")); + this.toolHelper.writeInfo("Building image \"" + imageToBuild + "\" using the Oryx++ Builder"); // Set the Oryx++ Builder as the default builder locally return [4 /*yield*/, this.appHelper.setDefaultBuilder()]; case 3: @@ -545,7 +545,7 @@ var azurecontainerapps = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - this.toolHelper.writeInfo("Building image \"".concat(imageToBuild, "\" using the provided Dockerfile")); + this.toolHelper.writeInfo("Building image \"" + imageToBuild + "\" using the provided Dockerfile"); return [4 /*yield*/, this.appHelper.createRunnableAppImageFromDockerfile(imageToBuild, appSourcePath, dockerfilePath)]; case 1: _a.sent(); @@ -573,7 +573,7 @@ var azurecontainerapps = /** @class */ (function () { // Pass the Container Registry credentials when creating a Container App or updating a Container App via the 'up' command if (!this.util.isNullOrEmpty(this.registryUrl) && !this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword) && (!this.containerAppExists || (this.containerAppExists && !this.shouldUseUpdateCommand))) { - this.commandLineArgs.push("--registry-server ".concat(this.registryUrl), "--registry-username ".concat(this.registryUsername), "--registry-password ".concat(this.registryPassword)); + this.commandLineArgs.push("--registry-server " + this.registryUrl, "--registry-username " + this.registryUsername, "--registry-password " + this.registryPassword); } // Determine default values only for the 'create' scenario to avoid overriding existing values for the 'update' scenario if (!this.containerAppExists) { @@ -581,7 +581,7 @@ var azurecontainerapps = /** @class */ (function () { // Set the ingress value to 'external' if it was not provided if (this.util.isNullOrEmpty(this.ingress)) { this.ingress = 'external'; - this.toolHelper.writeInfo("Default ingress value: ".concat(this.ingress)); + this.toolHelper.writeInfo("Default ingress value: " + this.ingress); } // Set the value of ingressEnabled to 'false' if ingress was provided as 'disabled' if (this.ingress == 'disabled') { @@ -595,12 +595,12 @@ var azurecontainerapps = /** @class */ (function () { // Set the target port to 80 if it was not provided if (this.util.isNullOrEmpty(this.targetPort)) { this.targetPort = '80'; - this.toolHelper.writeInfo("Default target port: ".concat(this.targetPort)); + this.toolHelper.writeInfo("Default target port: " + this.targetPort); } // Add the ingress value and target port to the optional arguments array // Note: this step should be skipped if we're updating an existing Container App (ingress is enabled via a separate command) - this.commandLineArgs.push("--ingress ".concat(this.ingress)); - this.commandLineArgs.push("--target-port ".concat(this.targetPort)); + this.commandLineArgs.push("--ingress " + this.ingress); + this.commandLineArgs.push("--target-port " + this.targetPort); } } var environmentVariables = this.toolHelper.getInput('environmentVariables', false); @@ -609,17 +609,17 @@ var azurecontainerapps = /** @class */ (function () { // The --replace-env-vars flag is only used for the 'update' command, // otherwise --env-vars is used for 'create' and 'up' if (this.shouldUseUpdateCommand) { - this.commandLineArgs.push("--replace-env-vars ".concat(environmentVariables)); + this.commandLineArgs.push("--replace-env-vars " + environmentVariables); } else { - this.commandLineArgs.push("--env-vars ".concat(environmentVariables)); + this.commandLineArgs.push("--env-vars " + environmentVariables); } } if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { - this.commandLineArgs.push("-i ".concat(this.imageToDeploy)); + this.commandLineArgs.push("-i " + this.imageToDeploy); } if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { - this.commandLineArgs.push("--source ".concat(this.appSourcePath)); + this.commandLineArgs.push("--source " + this.appSourcePath); } }; /** @@ -4681,7 +4681,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -4702,7 +4702,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.__esModule = true; exports.ContainerAppHelper = void 0; var path = __nccwpck_require__(1017); var os = __nccwpck_require__(2037); @@ -4735,13 +4735,13 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to create Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to create Container App with name \"" + containerAppName + "\" in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_1 = "az containerapp create -n ".concat(containerAppName, " -g ").concat(resourceGroup, " --environment ").concat(environment, " --output none"); + command_1 = "az containerapp create -n " + containerAppName + " -g " + resourceGroup + " --environment " + environment + " --output none"; optionalCmdArgs.forEach(function (val) { - command_1 += " ".concat(val); + command_1 += " " + val; }); return [4 /*yield*/, util.execute(command_1)]; case 2: @@ -4768,13 +4768,13 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to create Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to create Container App with name \"" + containerAppName + "\" in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_2 = "az containerapp up -n ".concat(containerAppName, " -g ").concat(resourceGroup, " -l northcentralusstage"); + command_2 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup + " -l northcentralusstage"; optionalCmdArgs.forEach(function (val) { - command_2 += " ".concat(val); + command_2 += " " + val; }); return [4 /*yield*/, util.execute(command_2)]; case 2: @@ -4801,11 +4801,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to create Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\" from provided YAML \"").concat(yamlConfigPath, "\"")); + toolHelper.writeDebug("Attempting to create Container App with name \"" + containerAppName + "\" in resource group \"" + resourceGroup + "\" from provided YAML \"" + yamlConfigPath + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp create -n ".concat(containerAppName, " -g ").concat(resourceGroup, " --yaml ").concat(yamlConfigPath, " --output none"); + command = "az containerapp create -n " + containerAppName + " -g " + resourceGroup + " --yaml " + yamlConfigPath + " --output none"; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); @@ -4831,13 +4831,13 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to update Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\" ")); + toolHelper.writeDebug("Attempting to update Container App with name \"" + containerAppName + "\" in resource group \"" + resourceGroup + "\" "); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_3 = "az containerapp update -n ".concat(containerAppName, " -g ").concat(resourceGroup, " --output none"); + command_3 = "az containerapp update -n " + containerAppName + " -g " + resourceGroup + " --output none"; optionalCmdArgs.forEach(function (val) { - command_3 += " ".concat(val); + command_3 += " " + val; }); return [4 /*yield*/, util.execute(command_3)]; case 2: @@ -4866,19 +4866,19 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to update Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to update Container App with name \"" + containerAppName + "\" in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_4 = "az containerapp up -n ".concat(containerAppName, " -g ").concat(resourceGroup); + command_4 = "az containerapp up -n " + containerAppName + " -g " + resourceGroup; optionalCmdArgs.forEach(function (val) { - command_4 += " ".concat(val); + command_4 += " " + val; }); if (!util.isNullOrEmpty(ingress)) { - command_4 += " --ingress ".concat(ingress); + command_4 += " --ingress " + ingress; } if (!util.isNullOrEmpty(targetPort)) { - command_4 += " --target-port ".concat(targetPort); + command_4 += " --target-port " + targetPort; } return [4 /*yield*/, util.execute(command_4)]; case 2: @@ -4905,11 +4905,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to update Container App with name \"".concat(containerAppName, "\" in resource group \"").concat(resourceGroup, "\" from provided YAML \"").concat(yamlConfigPath, "\"")); + toolHelper.writeDebug("Attempting to update Container App with name \"" + containerAppName + "\" in resource group \"" + resourceGroup + "\" from provided YAML \"" + yamlConfigPath + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp update -n ".concat(containerAppName, " -g ").concat(resourceGroup, " --yaml ").concat(yamlConfigPath, " --output none"); + command = "az containerapp update -n " + containerAppName + " -g " + resourceGroup + " --yaml " + yamlConfigPath + " --output none"; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); @@ -4935,11 +4935,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to determine if Container App with name \"".concat(containerAppName, "\" exists in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to determine if Container App with name \"" + containerAppName + "\" exists in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp show -n ".concat(containerAppName, " -g ").concat(resourceGroup, " -o none"); + command = "az containerapp show -n " + containerAppName + " -g " + resourceGroup + " -o none"; return [4 /*yield*/, util.execute(command)]; case 2: executionResult = _a.sent(); @@ -4965,11 +4965,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to determine if Container App Environment with name \"".concat(containerAppEnvironment, "\" exists in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to determine if Container App Environment with name \"" + containerAppEnvironment + "\" exists in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp env show -n ".concat(containerAppEnvironment, " -g ").concat(resourceGroup, " -o none"); + command = "az containerapp env show -n " + containerAppEnvironment + " -g " + resourceGroup + " -o none"; return [4 /*yield*/, util.execute(command)]; case 2: executionResult = _a.sent(); @@ -4994,11 +4994,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to determine if resource group \"".concat(resourceGroup, "\" exists")); + toolHelper.writeDebug("Attempting to determine if resource group \"" + resourceGroup + "\" exists"); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az group show -n ".concat(resourceGroup, " -o none"); + command = "az group show -n " + resourceGroup + " -o none"; return [4 /*yield*/, util.execute(command)]; case 2: executionResult = _a.sent(); @@ -5052,11 +5052,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to create resource group \"".concat(name, "\" in location \"").concat(location, "\"")); + toolHelper.writeDebug("Attempting to create resource group \"" + name + "\" in location \"" + location + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az group create -n ".concat(name, " -l ").concat(location); + command = "az group create -n " + name + " -l " + location; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); @@ -5081,11 +5081,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to get the existing Container App Environment in resource group \"".concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to get the existing Container App Environment in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp env list -g ".concat(resourceGroup, " --query \"[0].name\""); + command = "az containerapp env list -g " + resourceGroup + " --query \"[0].name\""; return [4 /*yield*/, util.execute(command)]; case 2: executionResult = _a.sent(); @@ -5112,13 +5112,13 @@ var ContainerAppHelper = /** @class */ (function () { switch (_a.label) { case 0: util = new Utility_1.Utility(); - toolHelper.writeDebug("Attempting to create Container App Environment with name \"".concat(name, "\" in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to create Container App Environment with name \"" + name + "\" in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp env create -n ".concat(name, " -g ").concat(resourceGroup); + command = "az containerapp env create -n " + name + " -g " + resourceGroup; if (!util.isNullOrEmpty(location)) { - command += " -l ".concat(location); + command += " -l " + location; } return [4 /*yield*/, util.execute(command)]; case 2: @@ -5144,11 +5144,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to disable ingress for Container App with name \"".concat(name, "\" in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to disable ingress for Container App with name \"" + name + "\" in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp ingress disable -n ".concat(name, " -g ").concat(resourceGroup); + command = "az containerapp ingress disable -n " + name + " -g " + resourceGroup; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); @@ -5176,11 +5176,11 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to set the Container Registry details for Container App with name \"".concat(name, "\" in resource group \"").concat(resourceGroup, "\"")); + toolHelper.writeDebug("Attempting to set the Container Registry details for Container App with name \"" + name + "\" in resource group \"" + resourceGroup + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "az containerapp registry set -n ".concat(name, " -g ").concat(resourceGroup, " --server ").concat(registryUrl, " --username ").concat(registryUsername, " --password ").concat(registryPassword); + command = "az containerapp registry set -n " + name + " -g " + resourceGroup + " --server " + registryUrl + " --username " + registryUsername + " --password " + registryPassword; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); @@ -5214,28 +5214,28 @@ var ContainerAppHelper = /** @class */ (function () { couldBuildImage = false; _loop_1 = function (builderImage) { var command_5, err_16; - return __generator(this, function (_b) { - switch (_b.label) { + return __generator(this, function (_a) { + switch (_a.label) { case 0: if (!util.isNullOrEmpty(builderStack) && !builderImage.includes(builderStack)) { return [2 /*return*/, "continue"]; } - toolHelper.writeDebug("Attempting to create a runnable application image with name \"".concat(imageToDeploy, "\" using the Oryx++ Builder \"").concat(builderImage, "\"")); - _b.label = 1; + toolHelper.writeDebug("Attempting to create a runnable application image with name \"" + imageToDeploy + "\" using the Oryx++ Builder \"" + builderImage + "\""); + _a.label = 1; case 1: - _b.trys.push([1, 3, , 4]); - command_5 = "build ".concat(imageToDeploy, " --path ").concat(appSourcePath, " --builder ").concat(builderImage, " --env ").concat(telemetryArg); + _a.trys.push([1, 3, , 4]); + command_5 = "build " + imageToDeploy + " --path " + appSourcePath + " --builder " + builderImage + " --env " + telemetryArg; environmentVariables.forEach(function (envVar) { - command_5 += " --env ".concat(envVar); + command_5 += " --env " + envVar; }); - return [4 /*yield*/, util.execute("".concat(PACK_CMD, " ").concat(command_5))]; + return [4 /*yield*/, util.execute(PACK_CMD + " " + command_5)]; case 2: - _b.sent(); + _a.sent(); couldBuildImage = true; return [2 /*return*/, "break"]; case 3: - err_16 = _b.sent(); - toolHelper.writeWarning("Unable to run 'pack build' command to produce runnable application image: ".concat(err_16.message)); + err_16 = _a.sent(); + toolHelper.writeWarning("Unable to run 'pack build' command to produce runnable application image: " + err_16.message); return [3 /*break*/, 4]; case 4: return [2 /*return*/]; } @@ -5281,15 +5281,15 @@ var ContainerAppHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to create a runnable application image from the provided/found Dockerfile \"".concat(dockerfilePath, "\" with image name \"").concat(imageToDeploy, "\"")); + toolHelper.writeDebug("Attempting to create a runnable application image from the provided/found Dockerfile \"" + dockerfilePath + "\" with image name \"" + imageToDeploy + "\""); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "docker build --file ".concat(dockerfilePath, " ").concat(appSourcePath, " --tag ").concat(imageToDeploy); + command = "docker build --file " + dockerfilePath + " " + appSourcePath + " --tag " + imageToDeploy; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); - toolHelper.writeDebug("Successfully created runnable application image from the provided/found Dockerfile \"".concat(dockerfilePath, "\" with image name \"").concat(imageToDeploy, "\"")); + toolHelper.writeDebug("Successfully created runnable application image from the provided/found Dockerfile \"" + dockerfilePath + "\" with image name \"" + imageToDeploy + "\""); return [3 /*break*/, 4]; case 3: err_17 = _a.sent(); @@ -5315,7 +5315,7 @@ var ContainerAppHelper = /** @class */ (function () { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "docker run --rm -v ".concat(appSourcePath, ":/app ").concat(ORYX_CLI_IMAGE, " /bin/bash -c \"oryx dockerfile /app | head -n 1 | sed 's/ARG RUNTIME=//' >> /app/oryx-runtime.txt\""); + command = "docker run --rm -v " + appSourcePath + ":/app " + ORYX_CLI_IMAGE + " /bin/bash -c \"oryx dockerfile /app | head -n 1 | sed 's/ARG RUNTIME=//' >> /app/oryx-runtime.txt\""; return [4 /*yield*/, util.execute(command) // Read the temp file to get the runtime stack into a variable ]; @@ -5325,14 +5325,14 @@ var ContainerAppHelper = /** @class */ (function () { runtimeStack = fs.promises.readFile(oryxRuntimeTxtPath_1, 'utf8').then(function (data) { var lines = data.split('\n'); return lines[0]; - }).catch(function (err) { + })["catch"](function (err) { toolHelper.writeError(err.message); throw err; }); // Delete the temp file fs.unlink(oryxRuntimeTxtPath_1, function (err) { if (err) { - toolHelper.writeWarning("Unable to delete the temporary file \"".concat(oryxRuntimeTxtPath_1, "\". Error: ").concat(err.message)); + toolHelper.writeWarning("Unable to delete the temporary file \"" + oryxRuntimeTxtPath_1 + "\". Error: " + err.message); } }); return [2 /*return*/, runtimeStack]; @@ -5359,8 +5359,8 @@ var ContainerAppHelper = /** @class */ (function () { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "config default-builder ".concat(ORYX_BUILDER_IMAGES[0]); - return [4 /*yield*/, util.execute("".concat(PACK_CMD, " ").concat(command))]; + command = "config default-builder " + ORYX_BUILDER_IMAGES[0]; + return [4 /*yield*/, util.execute(PACK_CMD + " " + command)]; case 2: _a.sent(); return [3 /*break*/, 4]; @@ -5392,22 +5392,22 @@ var ContainerAppHelper = /** @class */ (function () { if (IS_WINDOWS_AGENT) { packZipDownloadUri = 'https://github.com/buildpacks/pack/releases/download/v0.31.0/pack-v0.31.0-windows.zip'; packZipDownloadFilePath = path.join(PACK_CMD, 'pack-windows.zip'); - command = "New-Item -ItemType Directory -Path ".concat(PACK_CMD, " -Force | Out-Null; Invoke-WebRequest -Uri ").concat(packZipDownloadUri, " -OutFile ").concat(packZipDownloadFilePath, "; Expand-Archive -LiteralPath ").concat(packZipDownloadFilePath, " -DestinationPath ").concat(PACK_CMD, "; Remove-Item -Path ").concat(packZipDownloadFilePath); + command = "New-Item -ItemType Directory -Path " + PACK_CMD + " -Force | Out-Null; Invoke-WebRequest -Uri " + packZipDownloadUri + " -OutFile " + packZipDownloadFilePath + "; Expand-Archive -LiteralPath " + packZipDownloadFilePath + " -DestinationPath " + PACK_CMD + "; Remove-Item -Path " + packZipDownloadFilePath; commandLine = 'pwsh'; } else { tgzSuffix = os.platform() == 'darwin' ? 'macos' : 'linux'; - command = "(curl -sSL \"https://github.com/buildpacks/pack/releases/download/v0.31.0/pack-v0.31.0-".concat(tgzSuffix, ".tgz\" | ") + + command = "(curl -sSL \"https://github.com/buildpacks/pack/releases/download/v0.31.0/pack-v0.31.0-" + tgzSuffix + ".tgz\" | " + 'tar -C /usr/local/bin/ --no-same-owner -xzv pack)'; commandLine = 'bash'; } - return [4 /*yield*/, util.execute("".concat(commandLine, " -c \"").concat(command, "\""))]; + return [4 /*yield*/, util.execute(commandLine + " -c \"" + command + "\"")]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: err_20 = _a.sent(); - toolHelper.writeError("Unable to install the pack CLI. Error: ".concat(err_20.message)); + toolHelper.writeError("Unable to install the pack CLI. Error: " + err_20.message); throw err_20; case 4: return [2 /*return*/]; } @@ -5427,14 +5427,14 @@ var ContainerAppHelper = /** @class */ (function () { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command = "".concat(PACK_CMD, " config experimental true"); + command = PACK_CMD + " config experimental true"; return [4 /*yield*/, util.execute(command)]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: err_21 = _a.sent(); - toolHelper.writeError("Unable to enable experimental features for the pack CLI: ".concat(err_21.message)); + toolHelper.writeError("Unable to enable experimental features for the pack CLI: " + err_21.message); throw err_21; case 4: return [2 /*return*/]; } @@ -5468,7 +5468,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -5489,7 +5489,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.__esModule = true; exports.ContainerRegistryHelper = void 0; var os = __nccwpck_require__(2037); var Utility_1 = __nccwpck_require__(2135); @@ -5511,17 +5511,17 @@ var ContainerRegistryHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to log in to Container Registry instance\"".concat(registryUrl, "\" with username and password credentials")); + toolHelper.writeDebug("Attempting to log in to Container Registry instance\"" + registryUrl + "\" with username and password credentials"); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - return [4 /*yield*/, util.execute("docker login --password-stdin --username ".concat(registryUsername, " ").concat(registryUrl), [], Buffer.from(registryPassword))]; + return [4 /*yield*/, util.execute("docker login --password-stdin --username " + registryUsername + " " + registryUrl, [], Buffer.from(registryPassword))]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: err_1 = _a.sent(); - toolHelper.writeError("Failed to log in to Container Registry instance \"".concat(registryUrl, "\" with username and password credentials")); + toolHelper.writeError("Failed to log in to Container Registry instance \"" + registryUrl + "\" with username and password credentials"); throw err_1; case 4: return [2 /*return*/]; } @@ -5539,18 +5539,18 @@ var ContainerRegistryHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to log in to ACR instance \"".concat(acrName, "\" with access token")); + toolHelper.writeDebug("Attempting to log in to ACR instance \"" + acrName + "\" with access token"); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); commandLine = os.platform() === 'win32' ? 'pwsh' : 'bash'; - return [4 /*yield*/, util.execute("".concat(commandLine, " -c \"CA_ADO_TASK_ACR_ACCESS_TOKEN=$(az acr login --name ").concat(acrName, " --output json --expose-token --only-show-errors | jq -r '.accessToken'); docker login ").concat(acrName, ".azurecr.io -u 00000000-0000-0000-0000-000000000000 -p $CA_ADO_TASK_ACR_ACCESS_TOKEN > /dev/null 2>&1\""))]; + return [4 /*yield*/, util.execute(commandLine + " -c \"CA_ADO_TASK_ACR_ACCESS_TOKEN=$(az acr login --name " + acrName + " --output json --expose-token --only-show-errors | jq -r '.accessToken'); docker login " + acrName + ".azurecr.io -u 00000000-0000-0000-0000-000000000000 -p $CA_ADO_TASK_ACR_ACCESS_TOKEN > /dev/null 2>&1\"")]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: err_2 = _a.sent(); - toolHelper.writeError("Failed to log in to ACR instance \"".concat(acrName, "\" with access token")); + toolHelper.writeError("Failed to log in to ACR instance \"" + acrName + "\" with access token"); throw err_2; case 4: return [2 /*return*/]; } @@ -5567,17 +5567,17 @@ var ContainerRegistryHelper = /** @class */ (function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - toolHelper.writeDebug("Attempting to push image \"".concat(imageToPush, "\" to Container Registry")); + toolHelper.writeDebug("Attempting to push image \"" + imageToPush + "\" to Container Registry"); _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - return [4 /*yield*/, util.execute("docker push ".concat(imageToPush))]; + return [4 /*yield*/, util.execute("docker push " + imageToPush)]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: err_3 = _a.sent(); - toolHelper.writeError("Failed to push image \"".concat(imageToPush, "\" to Container Registry. Error: ").concat(err_3.message)); + toolHelper.writeError("Failed to push image \"" + imageToPush + "\" to Container Registry. Error: " + err_3.message); throw err_3; case 4: return [2 /*return*/]; } @@ -5611,7 +5611,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -5632,7 +5632,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.__esModule = true; exports.GitHubActionsToolHelper = void 0; var core = __nccwpck_require__(3195); var io = __nccwpck_require__(9529); @@ -5674,7 +5674,7 @@ var GitHubActionsToolHelper = /** @class */ (function () { }, stderr: function (data) { stderr_1 += data.toString(); - }, + } }, input: inputOptions }; @@ -5710,10 +5710,10 @@ var GitHubActionsToolHelper = /** @class */ (function () { return io.which(tool, check); }; GitHubActionsToolHelper.prototype.getDefaultContainerAppName = function (containerAppName) { - containerAppName = "gh-action-app-".concat(this.getBuildId(), "-").concat(this.getBuildNumber()); + containerAppName = "gh-action-app-" + this.getBuildId() + "-" + this.getBuildNumber(); // Replace all '.' characters with '-' characters in the Container App name containerAppName = containerAppName.replace(/\./gi, "-"); - this.writeInfo("Default Container App name: ".concat(containerAppName)); + this.writeInfo("Default Container App name: " + containerAppName); return containerAppName; }; GitHubActionsToolHelper.prototype.getTelemetryArg = function () { @@ -5752,7 +5752,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -5773,7 +5773,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.__esModule = true; exports.TelemetryHelper = void 0; var Utility_1 = __nccwpck_require__(2135); var GitHubActionsToolHelper_1 = __nccwpck_require__(3185); @@ -5838,24 +5838,24 @@ var TelemetryHelper = /** @class */ (function () { _a.trys.push([1, 3, , 4]); resultArg = ''; if (!util.isNullOrEmpty(this.result)) { - resultArg = "--property result=".concat(this.result); + resultArg = "--property result=" + this.result; } scenarioArg = ''; if (!util.isNullOrEmpty(this.scenario)) { - scenarioArg = "--property scenario=".concat(this.scenario); + scenarioArg = "--property scenario=" + this.scenario; } errorMessageArg = ''; if (!util.isNullOrEmpty(this.errorMessage)) { - errorMessageArg = "--property errorMessage=".concat(this.errorMessage); + errorMessageArg = "--property errorMessage=" + this.errorMessage; } eventName = toolHelper.getEventName(); - return [4 /*yield*/, util.execute("docker run --rm ".concat(ORYX_CLI_IMAGE, " /bin/bash -c \"oryx telemetry --event-name ").concat(eventName, " --processing-time ").concat(taskLengthMilliseconds, " ").concat(resultArg, " ").concat(scenarioArg, " ").concat(errorMessageArg, "\""))]; + return [4 /*yield*/, util.execute("docker run --rm " + ORYX_CLI_IMAGE + " /bin/bash -c \"oryx telemetry --event-name " + eventName + " --processing-time " + taskLengthMilliseconds + " " + resultArg + " " + scenarioArg + " " + errorMessageArg + "\"")]; case 2: _a.sent(); return [3 /*break*/, 4]; case 3: err_1 = _a.sent(); - toolHelper.writeWarning("Skipping telemetry logging due to the following exception: ".concat(err_1.message)); + toolHelper.writeWarning("Skipping telemetry logging due to the following exception: " + err_1.message); return [3 /*break*/, 4]; case 4: return [2 /*return*/]; } @@ -5889,7 +5889,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); - while (g && (g = 0, op[0] && (_ = 0)), _) try { + while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { @@ -5910,7 +5910,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; -Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.__esModule = true; exports.Utility = void 0; // Note: This file is used to define utility functions that can be used across the project. var GitHubActionsToolHelper_1 = __nccwpck_require__(3185); @@ -5940,7 +5940,7 @@ var Utility = /** @class */ (function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, this.execute("az extension add --name containerapp --upgrade")]; + case 0: return [4 /*yield*/, this.execute("az extension add --name containerapp --version 0.3.43")]; case 1: _a.sent(); return [2 /*return*/]; diff --git a/src/Utility.ts b/src/Utility.ts index e8391aaf..d9dc0798 100644 --- a/src/Utility.ts +++ b/src/Utility.ts @@ -18,7 +18,7 @@ export class Utility { * Sets the Azure CLI to dynamically install extensions that are missing. */ public async setAzureCliDynamicInstall() { - await this.execute(`az extension add --name containerapp --upgrade`); + await this.execute(`az extension add --name containerapp --version 0.3.43`); } /** From 9511b8a83b4951275dd6654d4aee4fbeb1a2888a Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Wed, 8 Nov 2023 14:03:26 -0800 Subject: [PATCH 04/12] Modify update command --- dist/index.js | 3 ++- src/ContainerAppHelper.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 02557d1f..0c272690 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4835,10 +4835,11 @@ var ContainerAppHelper = /** @class */ (function () { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_3 = "az containerapp update -n " + containerAppName + " -g " + resourceGroup + " --output none"; + command_3 = "az containerapp update -n " + containerAppName + " -g " + resourceGroup; optionalCmdArgs.forEach(function (val) { command_3 += " " + val; }); + command_3 += " --output none"; return [4 /*yield*/, util.execute(command_3)]; case 2: _a.sent(); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index 9a2a51c3..c5c1789f 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -100,10 +100,11 @@ export class ContainerAppHelper { optionalCmdArgs: string[]) { toolHelper.writeDebug(`Attempting to update Container App with name "${containerAppName}" in resource group "${resourceGroup}" `); try { - let command = `az containerapp update -n ${containerAppName} -g ${resourceGroup} --output none`; + let command = `az containerapp update -n ${containerAppName} -g ${resourceGroup}`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); + command += ` --output none`; await util.execute(command); } catch (err) { toolHelper.writeError(err.message); From aa5b9cec3777795b6e2e6b25a7dc15c3f335dc2b Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Wed, 8 Nov 2023 14:12:07 -0800 Subject: [PATCH 05/12] Comment out imageToDeploy --- azurecontainerapps.ts | 6 +++--- dist/index.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index c55e2947..e2beca12 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -538,9 +538,9 @@ export class azurecontainerapps { } } - if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { - this.commandLineArgs.push(`-i ${this.imageToDeploy}`); - } + // if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { + // this.commandLineArgs.push(`-i ${this.imageToDeploy}`); + // } if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { this.commandLineArgs.push(`--source ${this.appSourcePath}`); diff --git a/dist/index.js b/dist/index.js index 0c272690..23665772 100644 --- a/dist/index.js +++ b/dist/index.js @@ -615,9 +615,9 @@ var azurecontainerapps = /** @class */ (function () { this.commandLineArgs.push("--env-vars " + environmentVariables); } } - if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { - this.commandLineArgs.push("-i " + this.imageToDeploy); - } + // if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { + // this.commandLineArgs.push(`-i ${this.imageToDeploy}`); + // } if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { this.commandLineArgs.push("--source " + this.appSourcePath); } From f8b23d9d8da03d4403533827f124d06a8fe8d958 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Wed, 8 Nov 2023 14:26:48 -0800 Subject: [PATCH 06/12] Add --debug to the update command --- dist/index.js | 2 +- src/ContainerAppHelper.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 23665772..81e1b85c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4839,7 +4839,7 @@ var ContainerAppHelper = /** @class */ (function () { optionalCmdArgs.forEach(function (val) { command_3 += " " + val; }); - command_3 += " --output none"; + command_3 += " --output none --debug"; return [4 /*yield*/, util.execute(command_3)]; case 2: _a.sent(); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index c5c1789f..de7b0e6c 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -104,7 +104,7 @@ export class ContainerAppHelper { optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); - command += ` --output none`; + command += ` --output none --debug`; await util.execute(command); } catch (err) { toolHelper.writeError(err.message); From 8a70be2063d9b31aaeb82889e2bb211a4f6b16bb Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Wed, 8 Nov 2023 15:05:24 -0800 Subject: [PATCH 07/12] Comment out `--source` --- azurecontainerapps.ts | 8 ++++---- dist/index.js | 12 ++++++------ src/ContainerAppHelper.ts | 3 ++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index e2beca12..21661d60 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -542,9 +542,9 @@ export class azurecontainerapps { // this.commandLineArgs.push(`-i ${this.imageToDeploy}`); // } - if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { - this.commandLineArgs.push(`--source ${this.appSourcePath}`); - } + // if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { + // this.commandLineArgs.push(`--source ${this.appSourcePath}`); + // } } /** @@ -580,7 +580,7 @@ export class azurecontainerapps { } // Update the Container App using the 'update' command - await this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.commandLineArgs); + await this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.imageToDeploy, this.commandLineArgs); } else if (createOrUpdateContainerAppWithUp) { await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs); } else { diff --git a/dist/index.js b/dist/index.js index 81e1b85c..5384883c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -618,9 +618,9 @@ var azurecontainerapps = /** @class */ (function () { // if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { // this.commandLineArgs.push(`-i ${this.imageToDeploy}`); // } - if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { - this.commandLineArgs.push("--source " + this.appSourcePath); - } + // if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { + // this.commandLineArgs.push(`--source ${this.appSourcePath}`); + // } }; /** * Creates or updates the Container App. @@ -671,7 +671,7 @@ var azurecontainerapps = /** @class */ (function () { _a.label = 11; case 11: // Update the Container App using the 'update' command - return [4 /*yield*/, this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.commandLineArgs)]; + return [4 /*yield*/, this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.imageToDeploy, this.commandLineArgs)]; case 12: // Update the Container App using the 'update' command _a.sent(); @@ -4825,7 +4825,7 @@ var ContainerAppHelper = /** @class */ (function () { * @param resourceGroup - the resource group that the existing Container App is found in * @param optionalCmdArgs - a set of optional command line arguments */ - ContainerAppHelper.prototype.updateContainerApp = function (containerAppName, resourceGroup, optionalCmdArgs) { + ContainerAppHelper.prototype.updateContainerApp = function (containerAppName, resourceGroup, imageToDeploy, optionalCmdArgs) { return __awaiter(this, void 0, void 0, function () { var command_3, err_4; return __generator(this, function (_a) { @@ -4835,7 +4835,7 @@ var ContainerAppHelper = /** @class */ (function () { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_3 = "az containerapp update -n " + containerAppName + " -g " + resourceGroup; + command_3 = "az containerapp update -n " + containerAppName + " -g " + resourceGroup + " -i " + imageToDeploy; optionalCmdArgs.forEach(function (val) { command_3 += " " + val; }); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index de7b0e6c..bde3921d 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -97,10 +97,11 @@ export class ContainerAppHelper { public async updateContainerApp( containerAppName: string, resourceGroup: string, + imageToDeploy: string, optionalCmdArgs: string[]) { toolHelper.writeDebug(`Attempting to update Container App with name "${containerAppName}" in resource group "${resourceGroup}" `); try { - let command = `az containerapp update -n ${containerAppName} -g ${resourceGroup}`; + let command = `az containerapp update -n ${containerAppName} -g ${resourceGroup} -i ${imageToDeploy}`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); From 4e1a23982b4d3681043e921a7e47f3f277d83df4 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Wed, 8 Nov 2023 15:34:29 -0800 Subject: [PATCH 08/12] Enable build and push from ghs --- azurecontainerapps.ts | 10 +++++----- dist/index.js | 14 +++++++------- src/ContainerAppHelper.ts | 3 +-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index 21661d60..7d9be3ab 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -41,7 +41,7 @@ export class azurecontainerapps { this.useCliToBuildAndPushImage = (useAzureContainerRegistry || this.useInternalRegistry); // If the application source was provided, build a runnable application image from it - if (!this.useCliToBuildAndPushImage && !this.util.isNullOrEmpty(this.appSourcePath)) { + if (!this.useInternalRegistry && !this.util.isNullOrEmpty(this.appSourcePath)) { await this.buildAndPushImageAsync(); } @@ -538,9 +538,9 @@ export class azurecontainerapps { } } - // if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { - // this.commandLineArgs.push(`-i ${this.imageToDeploy}`); - // } + if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { + this.commandLineArgs.push(`-i ${this.imageToDeploy}`); + } // if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { // this.commandLineArgs.push(`--source ${this.appSourcePath}`); @@ -580,7 +580,7 @@ export class azurecontainerapps { } // Update the Container App using the 'update' command - await this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.imageToDeploy, this.commandLineArgs); + await this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.commandLineArgs); } else if (createOrUpdateContainerAppWithUp) { await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs); } else { diff --git a/dist/index.js b/dist/index.js index 5384883c..b060af00 100644 --- a/dist/index.js +++ b/dist/index.js @@ -94,7 +94,7 @@ var azurecontainerapps = /** @class */ (function () { this.useInternalRegistry = this.util.isNullOrEmpty(this.registryUrl) && this.imageToBuild.startsWith(this.defaultRegistryServer); // Determine if the image should be built and pushed using the CLI this.useCliToBuildAndPushImage = (useAzureContainerRegistry || this.useInternalRegistry); - if (!(!this.useCliToBuildAndPushImage && !this.util.isNullOrEmpty(this.appSourcePath))) return [3 /*break*/, 9]; + if (!(!this.useInternalRegistry && !this.util.isNullOrEmpty(this.appSourcePath))) return [3 /*break*/, 9]; return [4 /*yield*/, this.buildAndPushImageAsync()]; case 8: _a.sent(); @@ -615,9 +615,9 @@ var azurecontainerapps = /** @class */ (function () { this.commandLineArgs.push("--env-vars " + environmentVariables); } } - // if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { - // this.commandLineArgs.push(`-i ${this.imageToDeploy}`); - // } + if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { + this.commandLineArgs.push("-i " + this.imageToDeploy); + } // if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { // this.commandLineArgs.push(`--source ${this.appSourcePath}`); // } @@ -671,7 +671,7 @@ var azurecontainerapps = /** @class */ (function () { _a.label = 11; case 11: // Update the Container App using the 'update' command - return [4 /*yield*/, this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.imageToDeploy, this.commandLineArgs)]; + return [4 /*yield*/, this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.commandLineArgs)]; case 12: // Update the Container App using the 'update' command _a.sent(); @@ -4825,7 +4825,7 @@ var ContainerAppHelper = /** @class */ (function () { * @param resourceGroup - the resource group that the existing Container App is found in * @param optionalCmdArgs - a set of optional command line arguments */ - ContainerAppHelper.prototype.updateContainerApp = function (containerAppName, resourceGroup, imageToDeploy, optionalCmdArgs) { + ContainerAppHelper.prototype.updateContainerApp = function (containerAppName, resourceGroup, optionalCmdArgs) { return __awaiter(this, void 0, void 0, function () { var command_3, err_4; return __generator(this, function (_a) { @@ -4835,7 +4835,7 @@ var ContainerAppHelper = /** @class */ (function () { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_3 = "az containerapp update -n " + containerAppName + " -g " + resourceGroup + " -i " + imageToDeploy; + command_3 = "az containerapp update -n " + containerAppName + " -g " + resourceGroup; optionalCmdArgs.forEach(function (val) { command_3 += " " + val; }); diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index bde3921d..de7b0e6c 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -97,11 +97,10 @@ export class ContainerAppHelper { public async updateContainerApp( containerAppName: string, resourceGroup: string, - imageToDeploy: string, optionalCmdArgs: string[]) { toolHelper.writeDebug(`Attempting to update Container App with name "${containerAppName}" in resource group "${resourceGroup}" `); try { - let command = `az containerapp update -n ${containerAppName} -g ${resourceGroup} -i ${imageToDeploy}`; + let command = `az containerapp update -n ${containerAppName} -g ${resourceGroup}`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); From dd269311bf9392f435c8ed3de2eeeb95b1d01074 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Wed, 8 Nov 2023 21:59:47 -0800 Subject: [PATCH 09/12] Build and push from gha --- .github/workflows/run-validation-oidc.yml | 679 ++++++++++++++++++++++ .github/workflows/run-validation.yml | 92 +++ azurecontainerapps.ts | 74 ++- dist/index.js | 82 ++- src/ContainerAppHelper.ts | 3 +- src/Utility.ts | 6 +- 6 files changed, 844 insertions(+), 92 deletions(-) create mode 100644 .github/workflows/run-validation-oidc.yml diff --git a/.github/workflows/run-validation-oidc.yml b/.github/workflows/run-validation-oidc.yml new file mode 100644 index 00000000..b26f30fc --- /dev/null +++ b/.github/workflows/run-validation-oidc.yml @@ -0,0 +1,679 @@ +name: Run validation on action + +on: + push: + branches: + - main + paths-ignore: + - '**.md' + pull_request: + branches: + - main + paths-ignore: + - '**.md' + +env: + TEST_FULL_ACR_NAME: ${{ vars.TEST_ACR_NAME }}.azurecr.io + TEST_IMAGE_REPOSITORY: github-actions/container-app + +jobs: + create-using-builder: + + name: 'Create app using builder' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'bs-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-${{ github.run_id }}' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + acrName: ${{ vars.TEST_ACR_NAME }} + acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} + acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + + + create-using-builder-and-internal-registry: + + name: 'Create app using builder and push to internal registry' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'bs-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-${{ github.run_id }}' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NO_ACR_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + + create-using-found-dockerfile: + + name: 'Create app using found Dockerfile' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'fd-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'gh-ca-fd-${{ github.run_id }}' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/Blazor_Function_Sample/blazor-sample-app' + acrName: ${{ vars.TEST_ACR_NAME }} + acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} + acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + + create-using-provided-dockerfile: + + name: 'Create app using provided Dockerfile' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'pd-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'gh-ca-pd-${{ github.run_id }}' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/Blazor_Function_Sample/blazor-sample-app' + dockerfilePath: 'Dockerfile' + acrName: ${{ vars.TEST_ACR_NAME }} + acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} + acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + + + create-using-image-linux: + + name: 'Create app using image on Linux runner' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_CONTAINER_APP_NAME: 'gh-ca-is-lin-${{ github.run_id }}' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + imageToDeploy: 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest' + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + create-using-image-windows: + + name: 'Create app using image on Windows runner' + runs-on: windows-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_CONTAINER_APP_NAME: 'gh-ca-is-win-${{ github.run_id }}' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + imageToDeploy: 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest' + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + create-using-image-new-env: + + name: 'Create app using image with new environment' + runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the OIDC JWT Token + timeout-minutes: 15 + + env: + TEST_CONTAINER_APP_NAME: 'gh-ca-is-ne-${{ github.run_id }}' + TEST_NEW_CONTAINER_APP_ENV: 'gh-ca-is-ne-${{ github.run_id }}-env' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + imageToDeploy: 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest' + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ env.TEST_NEW_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + - name: Get customer ID for workspace to delete + if: ${{ always() }} + shell: bash + run: | + CUSTOMER_ID=$(az containerapp env show -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -n ${{ env.TEST_NEW_CONTAINER_APP_ENV }} --query 'properties.appLogsConfiguration.logAnalyticsConfiguration.customerId') + echo "CUSTOMER_ID=${CUSTOMER_ID}" >> $GITHUB_ENV + + - name: Get name of workspace to delete + if: ${{ always() }} + shell: bash + run: | + WORKSPACE_NAME=$(az monitor log-analytics workspace list -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} --query '[?customerId == `${{ env.CUSTOMER_ID }}`].name | [0]') + echo "WORKSPACE_NAME=${WORKSPACE_NAME}" >> $GITHUB_ENV + + - name: Delete created Azure Container App environment + if: ${{ always() }} + shell: bash + run: az containerapp env delete -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -n ${{ env.TEST_NEW_CONTAINER_APP_ENV }} -y + + - name: Delete created workspace + if: ${{ always() }} + shell: bash + run: az monitor log-analytics workspace delete -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -n ${{ env.WORKSPACE_NAME }} -y + + create-using-builder-yaml: + + name: 'Create app using builder with YAML configuration' + runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'bs-yaml-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-yaml-${{ github.run_id }}' + TEST_YAML_FILE_PATH: '${{ github.workspace }}/yaml-samples/create-with-builder-simple.yaml' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Update values in YAML configuration file + shell: pwsh + run: | + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$SUBSCRIPTION_ID$', '${{ vars.TEST_SUBSCRIPTION_ID }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$RESOURCE_GROUP$', '${{ vars.TEST_RESOURCE_GROUP_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$CONTAINER_APP_ENV$', '${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$FULL_ACR_NAME$', '${{ env.TEST_FULL_ACR_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$ACR_USERNAME$', '${{ secrets.TEST_REGISTRY_USERNAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$ACR_PASSWORD$', '${{ secrets.TEST_REGISTRY_PASSWORD }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$IMAGE_REPOSITORY$', '${{ env.TEST_IMAGE_REPOSITORY }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$IMAGE_TAG$', '${{ env.TEST_IMAGE_TAG }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + yamlConfigPath: ${{ env.TEST_YAML_FILE_PATH }} + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + acrName: ${{ vars.TEST_ACR_NAME }} + acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} + acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + + create-using-image-yaml-linux: + + name: 'Create app using image with YAML configuration on Linux runner' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-yaml-lin-${{ github.run_id }}' + TEST_YAML_FILE_PATH: '${{ github.workspace }}/yaml-samples/create-with-image-simple.yaml' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Update values in YAML configuration file + shell: pwsh + run: | + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$SUBSCRIPTION_ID$', '${{ vars.TEST_SUBSCRIPTION_ID }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$RESOURCE_GROUP$', '${{ vars.TEST_RESOURCE_GROUP_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$CONTAINER_APP_ENV$', '${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + yamlConfigPath: ${{ env.TEST_YAML_FILE_PATH }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + create-using-image-yaml-windows: + + name: 'Create app using image with YAML configuration on Windows runner' + runs-on: windows-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-yaml-win-${{ github.run_id }}' + TEST_YAML_FILE_PATH: 'yaml-samples/create-with-image-simple.yaml' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Update values in YAML configuration file + shell: pwsh + run: | + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$SUBSCRIPTION_ID$', '${{ vars.TEST_SUBSCRIPTION_ID }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$RESOURCE_GROUP$', '${{ vars.TEST_RESOURCE_GROUP_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$CONTAINER_APP_ENV$', '${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + yamlConfigPath: ${{ env.TEST_YAML_FILE_PATH }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + update-using-builder: + + name: 'Update existing app using builder' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'bs-up-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'update-using-builder-app' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + acrName: ${{ vars.TEST_ACR_NAME }} + acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} + acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + + - name: Update Container App with existing image + if: ${{ always() }} + shell: bash + run: az containerapp update -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -i mcr.microsoft.com/azuredocs/containerapps-helloworld:latest + + update-using-builder-and-internal-registry: + + name: 'Update existing app using builder and push to internal registry' + runs-on: ubuntu-latest + permissions: + id-token: write #This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'bs-up-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'update-using-builder-app' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + containerAppName: ${{ env.TEST_EXISTING_CONTAINER_APP }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NO_ACR_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Update Container App with existing image + if: ${{ always() }} + shell: bash + run: az containerapp update -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -i mcr.microsoft.com/azuredocs/containerapps-helloworld:latest + + update-using-image: + + name: 'Update app using image' + runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_CONTAINER_APP_NAME: 'update-using-image-app' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + imageToDeploy: 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest' + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + containerAppEnvironment: ${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + update-using-image-yaml: + + name: 'Update app using image with YAML configuration' + runs-on: ubuntu-latest + permissions: + id-token: write # This is required for requesting the OIDC JWT Token + timeout-minutes: 10 + + env: + TEST_CONTAINER_APP_NAME: 'update-using-image-yaml-app' + TEST_YAML_FILE_PATH: '${{ github.workspace }}/yaml-samples/update-with-image-simple.yaml' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.TEST_CLIENT_ID }} + tenant-id: ${{ secrets.TEST_TENANT_ID }} + subscription-id: ${{ secrets.TEST_SUBSCRIPTION_ID }} + + - name: Update values in YAML configuration file + shell: pwsh + run: | + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$SUBSCRIPTION_ID$', '${{ vars.TEST_SUBSCRIPTION_ID }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$RESOURCE_GROUP$', '${{ vars.TEST_RESOURCE_GROUP_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$CONTAINER_APP_ENV$', '${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + yamlConfigPath: ${{ env.TEST_YAML_FILE_PATH }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} \ No newline at end of file diff --git a/.github/workflows/run-validation.yml b/.github/workflows/run-validation.yml index a6d1e0a7..f708a330 100644 --- a/.github/workflows/run-validation.yml +++ b/.github/workflows/run-validation.yml @@ -18,6 +18,7 @@ env: jobs: create-using-builder: + name: 'Create app using builder' runs-on: ubuntu-latest timeout-minutes: 10 @@ -59,8 +60,14 @@ jobs: shell: bash run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + create-using-builder-and-internal-registry: + name: 'Create app using builder and push to internal registry' runs-on: ubuntu-latest timeout-minutes: 10 @@ -99,6 +106,7 @@ jobs: create-using-found-dockerfile: + name: 'Create app using found Dockerfile' runs-on: ubuntu-latest timeout-minutes: 10 @@ -140,7 +148,13 @@ jobs: shell: bash run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + create-using-provided-dockerfile: + name: 'Create app using provided Dockerfile' runs-on: ubuntu-latest timeout-minutes: 10 @@ -183,6 +197,12 @@ jobs: shell: bash run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + + create-using-image-linux: name: 'Create app using image on Linux runner' @@ -304,7 +324,70 @@ jobs: shell: bash run: az monitor log-analytics workspace delete -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -n ${{ env.WORKSPACE_NAME }} -y + + create-using-builder-yaml: + + name: 'Create app using builder with YAML configuration' + runs-on: ubuntu-latest + timeout-minutes: 10 + + env: + TEST_IMAGE_TAG: 'bs-yaml-${{ github.run_id }}' + TEST_CONTAINER_APP_NAME: 'gh-ca-bs-yaml-${{ github.run_id }}' + TEST_YAML_FILE_PATH: '${{ github.workspace }}/yaml-samples/create-with-builder-simple.yaml' + + steps: + - name: Checkout action repository + uses: actions/checkout@v3 + + - name: Clone Oryx repository + uses: actions/checkout@v3 + with: + repository: microsoft/Oryx + path: oryx + + - name: Log in to Azure + uses: azure/login@v1 + with: + creds: ${{ secrets.TEST_AZURE_CREDENTIALS }} + + - name: Update values in YAML configuration file + shell: pwsh + run: | + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$SUBSCRIPTION_ID$', '${{ vars.TEST_SUBSCRIPTION_ID }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$RESOURCE_GROUP$', '${{ vars.TEST_RESOURCE_GROUP_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$CONTAINER_APP_ENV$', '${{ vars.TEST_EXISTING_CONTAINER_APP_ENV }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$FULL_ACR_NAME$', '${{ env.TEST_FULL_ACR_NAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$ACR_USERNAME$', '${{ secrets.TEST_REGISTRY_USERNAME }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$ACR_PASSWORD$', '${{ secrets.TEST_REGISTRY_PASSWORD }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$IMAGE_REPOSITORY$', '${{ env.TEST_IMAGE_REPOSITORY }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + (Get-Content ${{ env.TEST_YAML_FILE_PATH }}).Replace('$IMAGE_TAG$', '${{ env.TEST_IMAGE_TAG }}') | Set-Content ${{ env.TEST_YAML_FILE_PATH }} + + - name: Execute Azure Container Apps Build and Deploy Action + uses: ./ + with: + yamlConfigPath: ${{ env.TEST_YAML_FILE_PATH }} + appSourcePath: '${{ github.workspace }}/oryx/tests/SampleApps/DotNetCore/NetCore6PreviewWebApp' + acrName: ${{ vars.TEST_ACR_NAME }} + acrUsername: ${{ secrets.TEST_REGISTRY_USERNAME }} + acrPassword: ${{ secrets.TEST_REGISTRY_PASSWORD }} + containerAppName: ${{ env.TEST_CONTAINER_APP_NAME }} + resourceGroup: ${{ vars.TEST_RESOURCE_GROUP_NAME }} + imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} + disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + + - name: Delete created Azure Container App + if: ${{ always() }} + shell: bash + run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y + + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + create-using-image-yaml-linux: + name: 'Create app using image with YAML configuration on Linux runner' runs-on: ubuntu-latest timeout-minutes: 10 @@ -349,6 +432,7 @@ jobs: run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y create-using-image-yaml-windows: + name: 'Create app using image with YAML configuration on Windows runner' runs-on: windows-latest timeout-minutes: 10 @@ -393,6 +477,7 @@ jobs: run: az containerapp delete -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -y update-using-builder: + name: 'Update existing app using builder' runs-on: ubuntu-latest timeout-minutes: 10 @@ -429,12 +514,18 @@ jobs: imageToBuild: ${{ env.TEST_FULL_ACR_NAME }}/${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} + - name: Delete pushed image + if: ${{ always() }} + shell: bash + run: az acr repository delete -n ${{ vars.TEST_ACR_NAME }} -t ${{ env.TEST_IMAGE_REPOSITORY }}:${{ env.TEST_IMAGE_TAG }} -y + - name: Update Container App with existing image if: ${{ always() }} shell: bash run: az containerapp update -n ${{ env.TEST_CONTAINER_APP_NAME }} -g ${{ vars.TEST_RESOURCE_GROUP_NAME }} -i mcr.microsoft.com/azuredocs/containerapps-helloworld:latest update-using-builder-and-internal-registry: + name: 'Update existing app using builder and push to internal registry' runs-on: ubuntu-latest timeout-minutes: 10 @@ -499,6 +590,7 @@ jobs: disableTelemetry: ${{ vars.TEST_DISABLE_TELEMETRY }} update-using-image-yaml: + name: 'Update app using image with YAML configuration' runs-on: ubuntu-latest timeout-minutes: 10 diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index 7d9be3ab..39e27b21 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -31,14 +31,11 @@ export class azurecontainerapps { await this.authenticateAzureContainerRegistryAsync(); } - // Set up the Container App Image properties if it's not provided by the user. - this.setupContainerAppImageProperties(); + // Set up property to determine if the internal registry should be used + this.useInternalRegistry = this.util.isNullOrEmpty(this.registryUrl); - const useAzureContainerRegistry = !this.util.isNullOrEmpty(this.registryUrl) && this.registryUrl.endsWith('.azurecr.io'); - this.useInternalRegistry = this.util.isNullOrEmpty(this.registryUrl) && this.imageToBuild.startsWith(this.defaultRegistryServer); - - // Determine if the image should be built and pushed using the CLI - this.useCliToBuildAndPushImage = (useAzureContainerRegistry || this.useInternalRegistry); + // Set up property to trigger cloud build with 'up' command + this.createOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry; // If the application source was provided, build a runnable application image from it if (!this.useInternalRegistry && !this.util.isNullOrEmpty(this.appSourcePath)) { @@ -107,9 +104,8 @@ export class azurecontainerapps { private static ingress: string; private static targetPort: string; private static shouldUseUpdateCommand: boolean; - private static useCliToBuildAndPushImage: boolean; - private static defaultRegistryServer: string = 'default/'; private static useInternalRegistry: boolean; + private static createOrUpdateContainerAppWithUp: boolean; /** * Initializes the helpers used by this task. @@ -181,11 +177,11 @@ export class azurecontainerapps { /** * Sets up the Azure CLI to be used for this task by logging in to Azure with the provided service connection and - * setting the Azure CLI to dynamically install missing extensions. + * setting the Azure CLI to install missing extensions. */ private static async setupAzureCli() { - // Set the Azure CLI to dynamically install missing extensions - await this.util.setAzureCliDynamicInstall(); + // Set the Azure CLI to install missing extensions + await this.util.installAzureCliExtension(); } /** @@ -350,32 +346,27 @@ export class azurecontainerapps { // If telemetry is enabled, log that the previously built image scenario was targeted for this task this.telemetryHelper.setImageScenario(); } - /** - * Sets up the Container App Image properties if it's not provided by the user. - */ - private static setupContainerAppImageProperties() { - // Get the name of the image to build if it was provided, or generate it from build variables - this.imageToBuild = this.toolHelper.getInput('imageToBuild', false); - - if (this.util.isNullOrEmpty(this.imageToBuild)) { - const imageRepository = this.toolHelper.getDefaultImageRepository() - // Constructs the image to build based on the provided registry URL, image repository, build ID, and build number. - // If the registry URL is not provided or is empty, the default registry server is used; otherwise, the provided registry URL is used. - this.imageToBuild = this.util.isNullOrEmpty(this.registryUrl) ? `${this.defaultRegistryServer}${imageRepository}:${this.buildId}.${this.buildNumber}` : `${this.registryUrl}/${imageRepository}:${this.buildId}.${this.buildNumber}`; - this.toolHelper.writeInfo(`Default image to build: ${this.imageToBuild}`); - } - - // Get the name of the image to deploy if it was provided, or set it to the value of 'imageToBuild' - if (this.util.isNullOrEmpty(this.imageToDeploy)) { - this.imageToDeploy = this.imageToBuild; - this.toolHelper.writeInfo(`Default image to deploy: ${this.imageToDeploy}`); - } - } /** * Builds a runnable application image using a Dockerfile or the builder and pushes it to the Container Registry. */ private static async buildAndPushImageAsync() { + // Get the name of the image to build if it was provided, or generate it from build variables + this.imageToBuild = this.toolHelper.getInput('imageToBuild', false); + + if (this.util.isNullOrEmpty(this.imageToBuild)) { + const imageRepository = this.toolHelper.getDefaultImageRepository() + // Constructs the image to build based on the provided registry URL, image repository, build ID, and build number. + this.imageToBuild = `${this.registryUrl}/${imageRepository}:${this.buildId}.${this.buildNumber}`; + this.toolHelper.writeInfo(`Default image to build: ${this.imageToBuild}`); + } + + // Get the name of the image to deploy if it was provided, or set it to the value of 'imageToBuild' + if (this.util.isNullOrEmpty(this.imageToDeploy)) { + this.imageToDeploy = this.imageToBuild; + this.toolHelper.writeInfo(`Default image to deploy: ${this.imageToDeploy}`); + } + // Get Dockerfile to build, if provided, or check if one exists at the root of the provided application let dockerfilePath: string = this.toolHelper.getInput('dockerfilePath', false); if (this.util.isNullOrEmpty(dockerfilePath)) { @@ -538,25 +529,26 @@ export class azurecontainerapps { } } - if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { + // 'imageToDeploy' argument is set only for non cloud build scenarios + if (!this.util.isNullOrEmpty(this.imageToDeploy)) { this.commandLineArgs.push(`-i ${this.imageToDeploy}`); } - // if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { - // this.commandLineArgs.push(`--source ${this.appSourcePath}`); - // } + // 'source' argument is set only for cloud build scenarios + if (this.createOrUpdateContainerAppWithUp) { + this.commandLineArgs.push(`--source ${this.appSourcePath}`); + } } /** * Creates or updates the Container App. */ private static async createOrUpdateContainerApp() { - var createOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry if (!this.containerAppExists) { if (!this.util.isNullOrEmpty(this.yamlConfigPath)) { // Create the Container App from the YAML configuration file await this.appHelper.createContainerAppFromYaml(this.containerAppName, this.resourceGroup, this.yamlConfigPath); - } else if (createOrUpdateContainerAppWithUp) { + } else if (this.createOrUpdateContainerAppWithUp) { await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs); } else { // Create the Container App from command line arguments @@ -573,7 +565,7 @@ export class azurecontainerapps { return; } - if (this.shouldUseUpdateCommand && !createOrUpdateContainerAppWithUp) { + if (this.shouldUseUpdateCommand && !this.createOrUpdateContainerAppWithUp) { // Update the Container Registry details on the existing Container App, if provided as an input if (!this.util.isNullOrEmpty(this.registryUrl) && !this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword)) { await this.appHelper.updateContainerAppRegistryDetails(this.containerAppName, this.resourceGroup, this.registryUrl, this.registryUsername, this.registryPassword); @@ -581,7 +573,7 @@ export class azurecontainerapps { // Update the Container App using the 'update' command await this.appHelper.updateContainerApp(this.containerAppName, this.resourceGroup, this.commandLineArgs); - } else if (createOrUpdateContainerAppWithUp) { + } else if (this.createOrUpdateContainerAppWithUp) { await this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs); } else { // Update the Container App using the 'up' command diff --git a/dist/index.js b/dist/index.js index b060af00..8b04be26 100644 --- a/dist/index.js +++ b/dist/index.js @@ -56,7 +56,7 @@ var azurecontainerapps = /** @class */ (function () { } azurecontainerapps.runMain = function () { return __awaiter(this, void 0, void 0, function () { - var useAzureContainerRegistry, err_1; + var err_1; return __generator(this, function (_a) { switch (_a.label) { case 0: @@ -88,12 +88,10 @@ var azurecontainerapps = /** @class */ (function () { _a.sent(); _a.label = 7; case 7: - // Set up the Container App Image properties if it's not provided by the user. - this.setupContainerAppImageProperties(); - useAzureContainerRegistry = !this.util.isNullOrEmpty(this.registryUrl) && this.registryUrl.endsWith('.azurecr.io'); - this.useInternalRegistry = this.util.isNullOrEmpty(this.registryUrl) && this.imageToBuild.startsWith(this.defaultRegistryServer); - // Determine if the image should be built and pushed using the CLI - this.useCliToBuildAndPushImage = (useAzureContainerRegistry || this.useInternalRegistry); + // Set up property to determine if the internal registry should be used + this.useInternalRegistry = this.util.isNullOrEmpty(this.registryUrl); + // Set up property to trigger cloud build with 'up' command + this.createOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry; if (!(!this.useInternalRegistry && !this.util.isNullOrEmpty(this.appSourcePath))) return [3 /*break*/, 9]; return [4 /*yield*/, this.buildAndPushImageAsync()]; case 8: @@ -186,17 +184,17 @@ var azurecontainerapps = /** @class */ (function () { }; /** * Sets up the Azure CLI to be used for this task by logging in to Azure with the provided service connection and - * setting the Azure CLI to dynamically install missing extensions. + * setting the Azure CLI to install missing extensions. */ azurecontainerapps.setupAzureCli = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { case 0: - // Set the Azure CLI to dynamically install missing extensions - return [4 /*yield*/, this.util.setAzureCliDynamicInstall()]; + // Set the Azure CLI to install missing extensions + return [4 /*yield*/, this.util.installAzureCliExtension()]; case 1: - // Set the Azure CLI to dynamically install missing extensions + // Set the Azure CLI to install missing extensions _a.sent(); return [2 /*return*/]; } @@ -413,34 +411,28 @@ var azurecontainerapps = /** @class */ (function () { // If telemetry is enabled, log that the previously built image scenario was targeted for this task this.telemetryHelper.setImageScenario(); }; - /** - * Sets up the Container App Image properties if it's not provided by the user. - */ - azurecontainerapps.setupContainerAppImageProperties = function () { - // Get the name of the image to build if it was provided, or generate it from build variables - this.imageToBuild = this.toolHelper.getInput('imageToBuild', false); - if (this.util.isNullOrEmpty(this.imageToBuild)) { - var imageRepository = this.toolHelper.getDefaultImageRepository(); - // Constructs the image to build based on the provided registry URL, image repository, build ID, and build number. - // If the registry URL is not provided or is empty, the default registry server is used; otherwise, the provided registry URL is used. - this.imageToBuild = this.util.isNullOrEmpty(this.registryUrl) ? "" + this.defaultRegistryServer + imageRepository + ":" + this.buildId + "." + this.buildNumber : this.registryUrl + "/" + imageRepository + ":" + this.buildId + "." + this.buildNumber; - this.toolHelper.writeInfo("Default image to build: " + this.imageToBuild); - } - // Get the name of the image to deploy if it was provided, or set it to the value of 'imageToBuild' - if (this.util.isNullOrEmpty(this.imageToDeploy)) { - this.imageToDeploy = this.imageToBuild; - this.toolHelper.writeInfo("Default image to deploy: " + this.imageToDeploy); - } - }; /** * Builds a runnable application image using a Dockerfile or the builder and pushes it to the Container Registry. */ azurecontainerapps.buildAndPushImageAsync = function () { return __awaiter(this, void 0, void 0, function () { - var dockerfilePath, rootDockerfilePath; + var imageRepository, dockerfilePath, rootDockerfilePath; return __generator(this, function (_a) { switch (_a.label) { case 0: + // Get the name of the image to build if it was provided, or generate it from build variables + this.imageToBuild = this.toolHelper.getInput('imageToBuild', false); + if (this.util.isNullOrEmpty(this.imageToBuild)) { + imageRepository = this.toolHelper.getDefaultImageRepository(); + // Constructs the image to build based on the provided registry URL, image repository, build ID, and build number. + this.imageToBuild = this.registryUrl + "/" + imageRepository + ":" + this.buildId + "." + this.buildNumber; + this.toolHelper.writeInfo("Default image to build: " + this.imageToBuild); + } + // Get the name of the image to deploy if it was provided, or set it to the value of 'imageToBuild' + if (this.util.isNullOrEmpty(this.imageToDeploy)) { + this.imageToDeploy = this.imageToBuild; + this.toolHelper.writeInfo("Default image to deploy: " + this.imageToDeploy); + } dockerfilePath = this.toolHelper.getInput('dockerfilePath', false); if (!this.util.isNullOrEmpty(dockerfilePath)) return [3 /*break*/, 4]; this.toolHelper.writeInfo("No Dockerfile path provided; checking for Dockerfile at root of application source."); @@ -615,23 +607,23 @@ var azurecontainerapps = /** @class */ (function () { this.commandLineArgs.push("--env-vars " + environmentVariables); } } - if (!this.imageToDeploy.startsWith(this.defaultRegistryServer)) { + // 'imageToDeploy' argument is set only for non cloud build scenarios + if (!this.util.isNullOrEmpty(this.imageToDeploy)) { this.commandLineArgs.push("-i " + this.imageToDeploy); } - // if (!this.util.isNullOrEmpty(this.appSourcePath) && this.useCliToBuildAndPushImage) { - // this.commandLineArgs.push(`--source ${this.appSourcePath}`); - // } + // 'source' argument is set only for cloud build scenarios + if (this.createOrUpdateContainerAppWithUp) { + this.commandLineArgs.push("--source " + this.appSourcePath); + } }; /** * Creates or updates the Container App. */ azurecontainerapps.createOrUpdateContainerApp = function () { return __awaiter(this, void 0, void 0, function () { - var createOrUpdateContainerAppWithUp; return __generator(this, function (_a) { switch (_a.label) { case 0: - createOrUpdateContainerAppWithUp = !this.util.isNullOrEmpty(this.appSourcePath) && this.useInternalRegistry; if (!!this.containerAppExists) return [3 /*break*/, 7]; if (!!this.util.isNullOrEmpty(this.yamlConfigPath)) return [3 /*break*/, 2]; // Create the Container App from the YAML configuration file @@ -641,7 +633,7 @@ var azurecontainerapps = /** @class */ (function () { _a.sent(); return [3 /*break*/, 6]; case 2: - if (!createOrUpdateContainerAppWithUp) return [3 /*break*/, 4]; + if (!this.createOrUpdateContainerAppWithUp) return [3 /*break*/, 4]; return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs)]; case 3: _a.sent(); @@ -663,7 +655,7 @@ var azurecontainerapps = /** @class */ (function () { _a.sent(); return [2 /*return*/]; case 9: - if (!(this.shouldUseUpdateCommand && !createOrUpdateContainerAppWithUp)) return [3 /*break*/, 13]; + if (!(this.shouldUseUpdateCommand && !this.createOrUpdateContainerAppWithUp)) return [3 /*break*/, 13]; if (!(!this.util.isNullOrEmpty(this.registryUrl) && !this.util.isNullOrEmpty(this.registryUsername) && !this.util.isNullOrEmpty(this.registryPassword))) return [3 /*break*/, 11]; return [4 /*yield*/, this.appHelper.updateContainerAppRegistryDetails(this.containerAppName, this.resourceGroup, this.registryUrl, this.registryUsername, this.registryPassword)]; case 10: @@ -677,7 +669,7 @@ var azurecontainerapps = /** @class */ (function () { _a.sent(); return [3 /*break*/, 17]; case 13: - if (!createOrUpdateContainerAppWithUp) return [3 /*break*/, 15]; + if (!this.createOrUpdateContainerAppWithUp) return [3 /*break*/, 15]; return [4 /*yield*/, this.appHelper.createOrUpdateContainerAppWithUp(this.containerAppName, this.resourceGroup, this.commandLineArgs)]; case 14: _a.sent(); @@ -700,7 +692,6 @@ var azurecontainerapps = /** @class */ (function () { }); }); }; - azurecontainerapps.defaultRegistryServer = 'default/'; return azurecontainerapps; }()); exports.azurecontainerapps = azurecontainerapps; @@ -4835,11 +4826,10 @@ var ContainerAppHelper = /** @class */ (function () { _a.label = 1; case 1: _a.trys.push([1, 3, , 4]); - command_3 = "az containerapp update -n " + containerAppName + " -g " + resourceGroup; + command_3 = "az containerapp update -n " + containerAppName + " -g " + resourceGroup + " --output none"; optionalCmdArgs.forEach(function (val) { command_3 += " " + val; }); - command_3 += " --output none --debug"; return [4 /*yield*/, util.execute(command_3)]; case 2: _a.sent(); @@ -5935,13 +5925,13 @@ var Utility = /** @class */ (function () { }); }; /** - * Sets the Azure CLI to dynamically install extensions that are missing. + * Sets the Azure CLI to install the containerapp extension. */ - Utility.prototype.setAzureCliDynamicInstall = function () { + Utility.prototype.installAzureCliExtension = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { switch (_a.label) { - case 0: return [4 /*yield*/, this.execute("az extension add --name containerapp --version 0.3.43")]; + case 0: return [4 /*yield*/, this.execute("az extension add --name containerapp --upgrade")]; case 1: _a.sent(); return [2 /*return*/]; diff --git a/src/ContainerAppHelper.ts b/src/ContainerAppHelper.ts index de7b0e6c..9a2a51c3 100644 --- a/src/ContainerAppHelper.ts +++ b/src/ContainerAppHelper.ts @@ -100,11 +100,10 @@ export class ContainerAppHelper { optionalCmdArgs: string[]) { toolHelper.writeDebug(`Attempting to update Container App with name "${containerAppName}" in resource group "${resourceGroup}" `); try { - let command = `az containerapp update -n ${containerAppName} -g ${resourceGroup}`; + let command = `az containerapp update -n ${containerAppName} -g ${resourceGroup} --output none`; optionalCmdArgs.forEach(function (val: string) { command += ` ${val}`; }); - command += ` --output none --debug`; await util.execute(command); } catch (err) { toolHelper.writeError(err.message); diff --git a/src/Utility.ts b/src/Utility.ts index d9dc0798..b5e2659b 100644 --- a/src/Utility.ts +++ b/src/Utility.ts @@ -15,10 +15,10 @@ export class Utility { } /** - * Sets the Azure CLI to dynamically install extensions that are missing. + * Sets the Azure CLI to install the containerapp extension. */ - public async setAzureCliDynamicInstall() { - await this.execute(`az extension add --name containerapp --version 0.3.43`); + public async installAzureCliExtension() { + await this.execute(`az extension add --name containerapp --upgrade`); } /** From a2bb8e120769f9fdc8131031a81178f6c047cbd8 Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Wed, 8 Nov 2023 23:16:25 -0800 Subject: [PATCH 10/12] Ensuer -i and --source are not used together --- azurecontainerapps.ts | 8 +++----- dist/index.js | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index 39e27b21..08ef14f3 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -529,15 +529,13 @@ export class azurecontainerapps { } } - // 'imageToDeploy' argument is set only for non cloud build scenarios + // Ensure '-i' argument and '--source' argument are not both provided if (!this.util.isNullOrEmpty(this.imageToDeploy)) { this.commandLineArgs.push(`-i ${this.imageToDeploy}`); - } - - // 'source' argument is set only for cloud build scenarios - if (this.createOrUpdateContainerAppWithUp) { + } else if (this.createOrUpdateContainerApp) { this.commandLineArgs.push(`--source ${this.appSourcePath}`); } + } /** diff --git a/dist/index.js b/dist/index.js index 8b04be26..306827e7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -607,12 +607,11 @@ var azurecontainerapps = /** @class */ (function () { this.commandLineArgs.push("--env-vars " + environmentVariables); } } - // 'imageToDeploy' argument is set only for non cloud build scenarios + // Ensure '-i' argument and '--source' argument are not both provided if (!this.util.isNullOrEmpty(this.imageToDeploy)) { this.commandLineArgs.push("-i " + this.imageToDeploy); } - // 'source' argument is set only for cloud build scenarios - if (this.createOrUpdateContainerAppWithUp) { + else if (this.createOrUpdateContainerApp) { this.commandLineArgs.push("--source " + this.appSourcePath); } }; From ab77c77f531316983dd0d772a19b3bff27a9c10d Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Wed, 8 Nov 2023 23:17:50 -0800 Subject: [PATCH 11/12] Fix typo --- azurecontainerapps.ts | 2 +- dist/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index 08ef14f3..7eb5dfa0 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -529,7 +529,7 @@ export class azurecontainerapps { } } - // Ensure '-i' argument and '--source' argument are not both provided + // Ensure 'imageToDeploy' argument and '--source' argument are not both provided if (!this.util.isNullOrEmpty(this.imageToDeploy)) { this.commandLineArgs.push(`-i ${this.imageToDeploy}`); } else if (this.createOrUpdateContainerApp) { diff --git a/dist/index.js b/dist/index.js index 306827e7..73de030b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -607,7 +607,7 @@ var azurecontainerapps = /** @class */ (function () { this.commandLineArgs.push("--env-vars " + environmentVariables); } } - // Ensure '-i' argument and '--source' argument are not both provided + // Ensure 'imageToDeploy' argument and '--source' argument are not both provided if (!this.util.isNullOrEmpty(this.imageToDeploy)) { this.commandLineArgs.push("-i " + this.imageToDeploy); } From 59f80dbc7d8a2607c4405ac42fc1dd33914c9fcd Mon Sep 17 00:00:00 2001 From: snehapar9 Date: Wed, 8 Nov 2023 23:30:13 -0800 Subject: [PATCH 12/12] Revert comment --- azurecontainerapps.ts | 2 +- dist/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/azurecontainerapps.ts b/azurecontainerapps.ts index 7eb5dfa0..08ef14f3 100644 --- a/azurecontainerapps.ts +++ b/azurecontainerapps.ts @@ -529,7 +529,7 @@ export class azurecontainerapps { } } - // Ensure 'imageToDeploy' argument and '--source' argument are not both provided + // Ensure '-i' argument and '--source' argument are not both provided if (!this.util.isNullOrEmpty(this.imageToDeploy)) { this.commandLineArgs.push(`-i ${this.imageToDeploy}`); } else if (this.createOrUpdateContainerApp) { diff --git a/dist/index.js b/dist/index.js index 73de030b..306827e7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -607,7 +607,7 @@ var azurecontainerapps = /** @class */ (function () { this.commandLineArgs.push("--env-vars " + environmentVariables); } } - // Ensure 'imageToDeploy' argument and '--source' argument are not both provided + // Ensure '-i' argument and '--source' argument are not both provided if (!this.util.isNullOrEmpty(this.imageToDeploy)) { this.commandLineArgs.push("-i " + this.imageToDeploy); }