containerapp/tomcat/README.md #111
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
schedule: | |
- cron: '0 5 * * 4' | |
workflow_dispatch: | |
name: 'containerapp/tomcat/README.md' | |
jobs: | |
validate: | |
runs-on: 'ubuntu-latest' | |
steps: | |
- uses: 'azure/login@v1' | |
with: | |
subscription-id: '${{ secrets.AZURE_SUBSCRIPTION_ID }}' | |
client-id: '${{ secrets.AZURE_CLIENT_ID }}' | |
tenant-id: '${{ secrets.AZURE_TENANT_ID }}' | |
- uses: 'actions/checkout@v3' | |
- run: | | |
if [[ -z $REGION ]]; then | |
export REGION=westus | |
fi | |
if [[ -z $REGION ]]; then | |
export REGION=westus | |
fi | |
if [[ -z $RESOURCE_GROUP ]]; then | |
export RESOURCE_GROUP=joaz-rg-$RANDOM | |
echo "Using '"$RESOURCE_GROUP"' as resource group" | |
fi | |
az group create --name $RESOURCE_GROUP --location $REGION | |
if [[ -z $ACR_NAME ]]; then | |
export ACR_NAME=joazcr$RANDOM | |
fi | |
az acr create \ | |
--name $ACR_NAME \ | |
--resource-group $RESOURCE_GROUP \ | |
--sku Basic \ | |
--admin-enabled true | |
cd acr/tomcat | |
mvn package | |
export ACR_TOMCAT_IMAGE=tomcat:latest | |
az acr build --registry $ACR_NAME --image $ACR_TOMCAT_IMAGE . | |
cd ../.. | |
if [[ -z $REGION ]]; then | |
export REGION=westus | |
fi | |
if [[ -z $RESOURCE_GROUP ]]; then | |
export RESOURCE_GROUP=joaz-rg-$RANDOM | |
echo "Using '"$RESOURCE_GROUP"' as resource group" | |
fi | |
az group create --name $RESOURCE_GROUP --location $REGION | |
az extension add --name containerapp --upgrade | |
az provider register --namespace Microsoft.App | |
az provider register --namespace Microsoft.OperationalInsights | |
if [[ -z $ACA_ENVIRONMENT_NAME ]]; then | |
export ACA_ENVIRONMENT_NAME=joazaca$RANDOM | |
export ACA_REGION=westus | |
fi | |
az containerapp env create \ | |
--name $ACA_ENVIRONMENT_NAME \ | |
--resource-group $RESOURCE_GROUP \ | |
--location "$ACA_REGION" || true | |
sleep 60 | |
export ACA_TOMCAT=tomcat | |
az containerapp create \ | |
--name $ACA_TOMCAT \ | |
--resource-group $RESOURCE_GROUP \ | |
--environment $ACA_ENVIRONMENT_NAME \ | |
--image $ACR_NAME.azurecr.io/$ACR_TOMCAT_IMAGE \ | |
--target-port 8080 \ | |
--ingress 'external' \ | |
--registry-server $ACR_NAME.azurecr.io \ | |
--min-replicas 1 | |
az containerapp show \ | |
--resource-group $RESOURCE_GROUP \ | |
--name $ACA_TOMCAT \ | |
--query properties.configuration.ingress.fqdn | |
sleep 60 | |
export URL=https://$(az containerapp show --resource-group $RESOURCE_GROUP --name $ACA_TOMCAT --query properties.configuration.ingress.fqdn --output tsv) | |
export RESULT=$(curl $URL) | |
az group delete --name $RESOURCE_GROUP --yes || true | |
if [[ "$RESULT" != *"custom Tomcat"* ]]; then | |
echo "Response did not contain 'custom Tomcat'" | |
exit 1 | |
fi | |
permissions: | |
contents: 'read' | |
id-token: 'write' |