Skip to content

Commit

Permalink
Merge v2-main branch into main (#87)
Browse files Browse the repository at this point in the history
* Convert composite action to typescript (#61)

* Convert docker action to typescript

* Add step to delete container app env back

* Remove workflow_dispatch

* Remove commented out code

* Fix formating

* Update image name

* Address PR comments

* Remove reference to Command Helper

* Address PR comments

* Remove commented code

* ci: add Azure Static Web Apps workflow file
on-behalf-of: @Azure [email protected]

* Delete .github/workflows/azure-static-web-apps-ashy-ocean-015179e0f.yml

* Update Azure CLI extensions installation

* Await setupAzureCli

* Refactor and trigger pipeline

* Refactor TelemetryHelper

* Reformat and remove new line

* Refactor and re-trigger pipeline

* Address PR comments

* Address PR comments

* Change comment for build-specific properties

* Refactor default containerapp name

* Change command construction

* Change command signature

* Fix command to get runtime stack

* Fix oryx dockerfile command to get runtime stack

* Fix oryx dockerfile command to get runtime stack

* Fix command to set default builder

* Test containerapp creation

* Hard code location and re-trigger pipeline

* Re-trigger pipeline and test

* Fix docker push command

* Address PR comments

* Fix formating for oryx dockerfile command

* Add double quotes

* Address PR comments

* Change executeAndThrowIfError to execute

* Support registry arguments

* Updated index.js

* Fix docker login command

* Re-order container registry authentication

* Add space

* Migrate latest changes from v1 to v2 (#68)

* Migrate latest changes from v1 to v2

* Support build arguments for Dockerfile and builder scenario

* Fix typo in docs

* 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 <[email protected]>

* Remove env as a required arg (#72)

* Remove env as a required arg

* Add index.js

* Address PR comments

* Remove env param

* Update targeted builders to 20231107.2

* Build and push non cloud scenarios from GHA (#75)

* Snap to containerapp version 0.3.43

* Modify update command

* Comment out imageToDeploy

* Add --debug to the update command

* Comment out `--source`

* Enable build and push from ghs

* Build and push from gha

* Ensuer -i and --source are not used together

* Fix typo

* Revert comment

* Add global var to determine cloud build scenario

* Remove location (#76)

* Remove location

* Change logic to set location

* Check if env is provided

* Fix logic to set location

* Update logic to set location

* Add comments

* Remove space

* Remove location param

* Remove location

* Refactor

* Reorder arguments

* Address PR comments

* Fix typo

* Fix typo

* Fix PR comments

* Address PR comments

* Revert change to set this.containerrAppExists

* Refactor

* Add comment

* Change validation pipeline name

* support build environment variable

* fix comiple error

* build ts file

* package ts file

* Revert "fix comiple error"

This reverts commit 6cecedf.

* fix validation error

* Update Container App with 'containerapp update'
and 'ingress update' commands

* support quotation mark

* fix validation

* add log

* build typescript to js

* Revert "fix comiple error"

This reverts commit 6cecedf.

* package ts to js

* define constant for regex

* build ts to js

* Update Container App and Ingress separately

* Addressed comment and kept support for admin cred

* Fixed typo in validation

* support docker file build for buildArguments

* Update Azure login secrets for OIDC testing

* refine readme format

* add validation for build environment variable

* refine env name validation logic

* Fixed typo and updated timeout on validation task

* Fixed mismatch resource group name in validation

* regenerate index.js

* fix merge mistake

* add examples for arg buildArguments

* add usage for buildArguments

* not validate build argument name when there's Dockerfile in root path

---------

Co-authored-by: snehapar9 <[email protected]>
Co-authored-by: Dan Vouaux <[email protected]>
Co-authored-by: daniv-msft <[email protected]>
Co-authored-by: yilims <[email protected]>
Co-authored-by: harrli <[email protected]>
Co-authored-by: Harry Li <[email protected]>
Co-authored-by: Yi Li <[email protected]>
  • Loading branch information
8 people authored Jan 9, 2024
1 parent 29ee198 commit 6537c41
Show file tree
Hide file tree
Showing 16 changed files with 9,284 additions and 596 deletions.
679 changes: 679 additions & 0 deletions .github/workflows/run-validation-oidc.yml

Large diffs are not rendered by default.

89 changes: 88 additions & 1 deletion .github/workflows/run-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:

jobs:
create-using-builder:

name: 'Create app using builder'
runs-on: ubuntu-latest
timeout-minutes: 10
Expand Down Expand Up @@ -64,7 +65,48 @@ jobs:
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

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 }}
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_NO_ACR_NAME }} -y


create-using-found-dockerfile:

name: 'Create app using found Dockerfile'
runs-on: ubuntu-latest
timeout-minutes: 10
Expand Down Expand Up @@ -112,6 +154,7 @@ jobs:
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
Expand Down Expand Up @@ -159,6 +202,7 @@ jobs:
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'
Expand Down Expand Up @@ -227,7 +271,7 @@ jobs:

name: 'Create app using image with new environment'
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 25

env:
TEST_CONTAINER_APP_NAME: 'gh-ca-is-ne-${{ github.run_id }}'
Expand Down Expand Up @@ -280,7 +324,9 @@ 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
Expand Down Expand Up @@ -341,6 +387,7 @@ jobs:
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
Expand Down Expand Up @@ -385,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
Expand Down Expand Up @@ -429,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
Expand Down Expand Up @@ -475,6 +524,44 @@ jobs:
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

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: 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 }}
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_NO_ACR_NAME }} -i mcr.microsoft.com/azuredocs/containerapps-helloworld:latest

update-using-image:

name: 'Update app using image'
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# .gitignore
node_modules/
*.js
!dist/index.js
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ For more information on the structure of the YAML configuration file, please vis
| `resourceGroup` | No | The existing resource group that the Azure Container App will be created in. If not provided, this value will be `<container-app-name>-rg` and its existence will first be checked before attempting to create it. |
| `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 `<container-app-name>-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 `<platform>:<version>`. 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. |
| `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-20231107.2", 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 space-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. |
Expand Down Expand Up @@ -419,6 +420,29 @@ steps:
This will create a new Container App named `github-action-container-app-<github-run-id>-<github-run-attempt>` in a new
resource group named `<container-app-name>-rg` where the runnable application image is using the .NET 7 runtime stack.

### Build Arguments provided

```yml
steps:
- name: Log in to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Build and deploy Container App
uses: azure/container-apps-deploy-action@v1
with:
appSourcePath: ${{ github.workspace }}
acrName: mytestacr
buildArguments: |
"BP_JVM_VERSION=21" "BP_MAVEN_BUILD_ARGUMENTS=-Dmaven.test.skip=false --no-transfer-progress package"
```

This will create a new Container App named `github-action-container-app-<github-run-id>-<github-run-attempt>` in a new
resource group named `<container-app-name>-rg`. The Container App will be based off of an image that was built from
the provided `appSourcePath`. 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, e.g., `BP_JVM_VERSION=21 BP_MAVEN_VERSION=4` will be passed to the `pack build` as `--env BP_JVM_VERSION=21 --env BP_MAVEN_VERSION=4`.'

### Dockerfile provided

```yml
Expand All @@ -435,11 +459,13 @@ steps:
appSourcePath: ${{ github.workspace }}
acrName: mytestacr
dockerfilePath: test.Dockerfile
buildArguments: |
"arg-1=value-1" "arg-2=value-2"
```

This will create a new Container App named `github-action-container-app-<github-run-id>-<github-run-attempt>` in a new
resource group named `<container-app-name>-rg` where the runnable application image was created from the `test.Dockerfile`
file found in the provided application source path directory.
file found in the provided application source path directory and build arguments `"arg-1=value-1" "arg-2=value-2"` will be passed to the `docker build` as `--build-arg "arg-1=value-1" --build-arg "arg-2=value-2"`. If there's no build argument in the Dockerfile, no need to provide `buildArguments`.

_Note_: for values provided to `dockerfilePath`, no file prefixes should be included (_e.g._, `./test.Dockerfile` should be
passed as just `test.Dockerfile`). The provided `appSourcePath` and `dockerfilePath` arguments will be concatenated inside
Expand Down
Loading

0 comments on commit 6537c41

Please sign in to comment.