diff --git a/.github/workflows/packer-build-if-vm.yml b/.github/workflows/packer-build-if-vm.yml index 4aa6a1ec..12dc9e76 100644 --- a/.github/workflows/packer-build-if-vm.yml +++ b/.github/workflows/packer-build-if-vm.yml @@ -33,30 +33,25 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 - # - name: Template packer vars file - # uses: cuchi/jinja2-action@v1.2.2 - # with: - # template: images/packer/image-factory-vm/values.auto.pkrvars.hcl.j2 - # output_file: images/packer/image-factory-vm/values.auto.pkrvars.hcl - - name: Azure Login uses: azure/login@v2 with: creds: ${{ env.AZURE_CREDENTIALS }} - - name: Create Image Definition + - name: Create Azure Image Definition uses: azure/cli@v2 with: azcliversion: 2.64.0 inlineScript: | set +e - image_definition_exists=$(az sig image-definition show \ + az sig image-definition show \ --resource-group "$AZURE_RESOURCE_GROUP" \ --gallery-name "$AZURE_ACG" \ --gallery-image-definition "$IMAGE_NAME" \ - --query "name" -o tsv) + --query "name" -o tsv + az_exit_code=$? set -e - if [ -z "$image_definition_exists" ]; then + if [ $az_exit_code -eq 3 ]; then echo "Image definition does not exist. Creating it..." az sig image-definition create \ --resource-group "$AZURE_RESOURCE_GROUP" \ @@ -70,3 +65,8 @@ jobs: echo "Image definition '$IMAGE_NAME' already exists." fi + # - name: Template packer vars file + # uses: cuchi/jinja2-action@v1.2.2 + # with: + # template: images/packer/image-factory-vm/values.auto.pkrvars.hcl.j2 + # output_file: images/packer/image-factory-vm/values.auto.pkrvars.hcl \ No newline at end of file