containerapp/glassfish/README.md #60
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 8 * * 3' | |
workflow_dispatch: | |
name: 'containerapp/glassfish/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/glassfish | |
mvn package | |
export ACR_GLASSFISH_IMAGE=glassfish:latest | |
az acr build --resource-group $RESOURCE_GROUP --registry $ACR_NAME --image $ACR_GLASSFISH_IMAGE . | |
az acr repository list --name $ACR_NAME --output table | |
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_GLASSFISH=glassfish | |
az containerapp create \ | |
--name $ACA_GLASSFISH \ | |
--resource-group $RESOURCE_GROUP \ | |
--environment $ACA_ENVIRONMENT_NAME \ | |
--image $ACR_NAME.azurecr.io/$ACR_GLASSFISH_IMAGE \ | |
--target-port 8080 \ | |
--ingress 'external' \ | |
--registry-server $ACR_NAME.azurecr.io \ | |
--min-replicas 1 | |
az containerapp show \ | |
--resource-group $RESOURCE_GROUP \ | |
--name $ACA_GLASSFISH \ | |
--query properties.configuration.ingress.fqdn \ | |
--output tsv | |
sleep 120 | |
export URL=https://$(az containerapp show --resource-group $RESOURCE_GROUP --name $ACA_GLASSFISH --query properties.configuration.ingress.fqdn --output tsv) | |
export RESULT=$(curl $URL) | |
az group delete --name $RESOURCE_GROUP --yes || true | |
if [[ "$RESULT" != *"custom Glassfish"* ]]; then | |
echo "Response did not contain 'custom Glassfish'" | |
exit 1 | |
fi | |
permissions: | |
contents: 'read' | |
id-token: 'write' |