Skip to content

Commit 239c44a

Browse files
committed
Updated Workflow to avoid hanging
1 parent 166d7da commit 239c44a

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

.github/workflows/deploy-azure.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,32 @@ jobs:
4242
- uses: hashicorp/setup-terraform@v2
4343

4444
- name: Terraform init
45-
run: terraform -chdir=infra/azure init
45+
env: { TF_IN_AUTOMATION: true } # disables interactive prompts
46+
run: terraform -chdir=infra/azure init -input=false -no-color
4647

47-
# NEW · Import RG if it already exists
48+
# TRY TO IMPORT THE RG IF IT ALREADY EXISTS
4849
- name: Import existing resource-group (if any)
4950
env:
51+
TF_IN_AUTOMATION: true
5052
RG_NAME: rg-aks-memgraph-${{ env.ENVIRONMENT }}
5153
run: |
5254
set -e
53-
if az group show --name "$RG_NAME" &>/dev/null; then
54-
echo "Resource-group $RG_NAME exists – importing into state"
55-
terraform -chdir=infra/azure import \
55+
if az group exists --name "$RG_NAME" | grep -q true; then
56+
echo "Resource-group $RG_NAME exists – importing"
57+
terraform -chdir=infra/azure \
58+
import \
59+
-input=false -lock=false -no-color \
5660
azurerm_resource_group.this \
5761
"/subscriptions/${ARM_SUBSCRIPTION_ID}/resourceGroups/$RG_NAME" \
58-
|| true # ignore if already in state
62+
|| true # ignore already in state
5963
else
6064
echo "Resource-group $RG_NAME not found – will be created"
6165
fi
6266
6367
- name: Terraform apply
68+
env: { TF_IN_AUTOMATION: true }
6469
run: |
65-
terraform -chdir=infra/azure apply -auto-approve \
70+
terraform -chdir=infra/azure apply -auto-approve -input=false -no-color \
6671
-var="subscription_id=${{ env.ARM_SUBSCRIPTION_ID }}" \
6772
-var="location=germanywestcentral" \
6873
-var="environment=${{ env.ENVIRONMENT }}" \

0 commit comments

Comments
 (0)