@@ -48,29 +48,13 @@ jobs:
4848 - name : Remove VM in case of canceled job
4949 if : cancelled()
5050 run : |
51- # Set your VM directory path
52- VM_DIR="$HOME/Documents/Virtual Machines.localized"
53- # VM name to search for (case-sensitive)
54- TARGET_VM_NAME="${{ matrix.os }}"
55- # List all VMs
56- echo "Listing all VMs in $VM_DIR..."
57- VM_PATHS=$(find "$VM_DIR" -name "*.vmx")
58- # Loop through each VM and match by name
59- for VMX in $VM_PATHS; do
60- if grep -q "$TARGET_VM_NAME" <<< "$VMX"; then
61- echo "Found VM: $VMX"
62- # Stop the VM
63- echo "Stopping VM..."
64- vmrun stop "$VMX" soft
65- # Wait a bit to ensure it's stopped
66- sleep 5
67- # Delete the VM directory
68- VM_FOLDER=$(dirname "$VMX")
69- echo "Deleting VM folder: $VM_FOLDER"
70- rm -rf "$VM_FOLDER"
71- echo "VM '$TARGET_VM_NAME' has been stopped and deleted."
72- fi
73- done
51+ VMX="$(find "$HOME/Documents/Virtual Machines.localized" -name "*.vmx" | grep '${{ matrix.os }}' | head -1)"
52+ echo "VMX Path: $VMX"
53+ if [ -n "$VMX" ]; then
54+ vmrun stop "$VMX" hard 2>/dev/null || true
55+ sleep 3
56+ rm -rf "$(dirname "$VMX")"
57+ fi
7458 - name : Bento Test
7559 run : |
7660 eval "$(chef shell-init bash)"
@@ -107,29 +91,13 @@ jobs:
10791 - name : Remove VM in case of canceled job
10892 if : cancelled()
10993 run : |
110- # Set your VM directory path
111- VM_DIR="$HOME/Documents/Virtual Machines.localized"
112- # VM name to search for (case-sensitive)
113- TARGET_VM_NAME="${{ matrix.os }}"
114- # List all VMs
115- echo "Listing all VMs in $VM_DIR..."
116- VM_PATHS=$(find "$VM_DIR" -name "*.vmx")
117- # Loop through each VM and match by name
118- for VMX in $VM_PATHS; do
119- if grep -q "$TARGET_VM_NAME" <<< "$VMX"; then
120- echo "Found VM: $VMX"
121- # Stop the VM
122- echo "Stopping VM..."
123- vmrun stop "$VMX" soft
124- # Wait a bit to ensure it's stopped
125- sleep 5
126- # Delete the VM directory
127- VM_FOLDER=$(dirname "$VMX")
128- echo "Deleting VM folder: $VM_FOLDER"
129- rm -rf "$VM_FOLDER"
130- echo "VM '$TARGET_VM_NAME' has been stopped and deleted."
131- fi
132- done
94+ VMX="$(find "$HOME/Documents/Virtual Machines.localized" -name "*.vmx" | grep '${{ matrix.os }}' | head -1)"
95+ echo "VMX Path: $VMX"
96+ if [ -n "$VMX" ]; then
97+ vmrun stop "$VMX" hard 2>/dev/null || true
98+ sleep 3
99+ rm -rf "$(dirname "$VMX")"
100+ fi
133101 - name : Bento Test
134102 run : |
135103 eval "$(chef shell-init bash)"
0 commit comments