appservice/container-payara/README.md #41
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 10 * * 4' | |
workflow_dispatch: | |
name: 'appservice/container-payara/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 $REGION ]]; then | |
export REGION=westus | |
fi | |
if [[ -z $RESOURCE_GROUP ]]; then | |
export RESOURCE_GROUP=joazrg-$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/payara | |
mvn package | |
export ACR_PAYARA_IMAGE=payara:latest | |
az acr build --registry $ACR_NAME --image $ACR_PAYARA_IMAGE . | |
cd ../.. | |
if [[ -z $REGION ]]; then | |
export REGION=westus | |
fi | |
if [[ -z $REGION ]]; then | |
export REGION=westus | |
fi | |
if [[ -z $RESOURCE_GROUP ]]; then | |
export RESOURCE_GROUP=joazrg-$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/create-settings-xml | |
export ACR_USERNAME=`az acr credential show --name $ACR_NAME \ | |
--resource-group $RESOURCE_GROUP --query username --output tsv` | |
export ACR_PASSWORD=`az acr credential show --name $ACR_NAME \ | |
--resource-group $RESOURCE_GROUP --query 'passwords[0].value' --output tsv` | |
export SETTINGS_XML=$PWD/settings.xml | |
cd ../.. | |
if [[ -z $REGION ]]; then | |
export REGION=westus | |
fi | |
if [[ -z $REGION ]]; then | |
export REGION=westus | |
fi | |
if [[ -z $RESOURCE_GROUP ]]; then | |
export RESOURCE_GROUP=joazrg-$RANDOM | |
echo "Using '"$RESOURCE_GROUP"' as resource group" | |
fi | |
az group create --name $RESOURCE_GROUP --location $REGION | |
if [[ -z $APPSERVICE_PLAN ]]; then | |
export APPSERVICE_PLAN=joazasp-$RANDOM | |
fi | |
az appservice plan create \ | |
--resource-group $RESOURCE_GROUP \ | |
--location $REGION \ | |
--name $APPSERVICE_PLAN \ | |
--is-linux \ | |
--sku P1v3 | |
cd appservice/container-payara | |
export APPSERVICE_CONTAINER_PAYARA=appservice-container-payara-$RANDOM | |
mvn azure-webapp:deploy \ | |
--settings=$SETTINGS_XML \ | |
-DappName=$APPSERVICE_CONTAINER_PAYARA \ | |
-DimageName=$ACR_PAYARA_IMAGE \ | |
-DappServicePlan=$APPSERVICE_PLAN \ | |
-DresourceGroup=$RESOURCE_GROUP \ | |
-DserverId=$ACR_NAME | |
az webapp show \ | |
--resource-group $RESOURCE_GROUP \ | |
--name $APPSERVICE_CONTAINER_PAYARA \ | |
--query hostNames[0] \ | |
--output tsv | |
sleep 180 | |
cd ../.. | |
export RESULT=$(az webapp show --resource-group $RESOURCE_GROUP --name $APPSERVICE_CONTAINER_PAYARA --output tsv --query state) | |
if [[ "$RESULT" != Running ]]; then | |
echo 'Web application is NOT running' | |
az group delete --name $RESOURCE_GROUP --yes || true | |
exit 1 | |
fi | |
export URL=https://$(az webapp show --resource-group $RESOURCE_GROUP --name $APPSERVICE_CONTAINER_PAYARA --output tsv --query defaultHostName) | |
export RESULT=$(curl $URL) | |
sleep 180 | |
export RESULT=$(curl $URL) | |
az group delete --name $RESOURCE_GROUP --yes || true | |
if [[ "$RESULT" != *"custom Payara"* ]]; then | |
echo "Response did not contain 'custom Payara'" | |
exit 1 | |
fi | |
permissions: | |
contents: 'read' | |
id-token: 'write' |