File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 runs-on : ubuntu-latest
1919 name : Validation steps
2020 environment : ' rti-validate'
21+ env :
22+ RG_TAGS : ${{ vars.RG_TAGS }}
2123 steps :
2224 - name : Checkout
2325 uses : actions/checkout@v4
26+
27+ - name : Add RG tags into Bicep parameter file
28+ shell : bash
29+ run : |
30+ # Parse RG_TAGS (format: "Key=Value Key2=Value2") into a JSON object
31+ TAG_JSON="{}"
32+ for tag in ${{ env.RG_TAGS }}; do
33+ KEY="${tag%%=*}"
34+ VALUE="${tag#*=}"
35+ TAG_JSON=$(echo "$TAG_JSON" | jq --arg k "$KEY" --arg v "$VALUE" '. + {($k): $v}')
36+ done
37+
38+ jq --argjson tags "$TAG_JSON" '.parameters.tags = {"value": $tags}' \
39+ infra/main.parameters.json > infra/main.parameters.tmp.json
40+ mv infra/main.parameters.tmp.json infra/main.parameters.json
41+ echo "✅ Added tags into main.parameters.json"
42+ cat infra/main.parameters.json
43+
2444 - name : Validate AZD template
2545 uses : microsoft/template-validation-action@Latest
2646 id : validation
3252 AZURE_ENV_NAME : ' ${{ vars.AZURE_ENV_NAME }}val'
3353 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
3454
35- - name : print result
55+ - name : Print result
3656 run : cat ${{ steps.validation.outputs.resultFile }}
Original file line number Diff line number Diff line change 3131 AZURE_SUBSCRIPTION_ID : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
3232 AZURE_LOCATION : ' westus3'
3333 PYTHONIOENCODING : utf-8
34+ RG_TAGS : ${{ vars.RG_TAGS }}
3435
3536jobs :
3637 build :
7677 rg_exists=$(az group exists --name $RESOURCE_GROUP_NAME)
7778 if [ "$rg_exists" = "false" ]; then
7879 echo "📦 Resource group does not exist. Creating new resource group '$RESOURCE_GROUP_NAME' in location '$AZURE_LOCATION'..."
79- az group create --name $RESOURCE_GROUP_NAME --location $AZURE_LOCATION || { echo "❌ Error creating resource group"; exit 1; }
80+ az group create --name $RESOURCE_GROUP_NAME --location $AZURE_LOCATION --tags ${{ env.RG_TAGS }} || { echo "❌ Error creating resource group"; exit 1; }
8081 echo "✅ Resource group '$RESOURCE_GROUP_NAME' created successfully."
8182 else
8283 echo "✅ Resource group '$RESOURCE_GROUP_NAME' already exists. Deploying to existing resource group."
You can’t perform that action at this time.
0 commit comments