From de172577410bd5b42343082558cd18b3bd5a7d35 Mon Sep 17 00:00:00 2001 From: Liang Wang Date: Fri, 28 Feb 2025 22:59:24 +0800 Subject: [PATCH 1/3] Fix Sample for Win --- .github/workflows/sample-workflow-win.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sample-workflow-win.yaml b/.github/workflows/sample-workflow-win.yaml index 739d623..9107ec7 100644 --- a/.github/workflows/sample-workflow-win.yaml +++ b/.github/workflows/sample-workflow-win.yaml @@ -27,4 +27,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: print result - run: cat ${{ steps.validation.outputs.resultFile }} \ No newline at end of file + run: | + # Change ${{ steps.validation.outputs.resultFile }} to windows path + resultFile_win=$(cygpath -w ${{ steps.validation.outputs.resultFile }}) + echo $resultFile_win + cat $resultFile_win + shell: bash \ No newline at end of file From 4883e6770d32ec705b0ce7fe5177ff489063158b Mon Sep 17 00:00:00 2001 From: Liang Wang Date: Wed, 5 Mar 2025 10:22:52 +0800 Subject: [PATCH 2/3] Upgrade OS Version --- .github/workflows/pr-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index 49e59aa..882e397 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - os: ["ubuntu-20.04"] + os: ["ubuntu-22.04"] python_version: ["3.11"] steps: - uses: actions/checkout@v4 From f9570142ee5d2e4e3ea2d7dc1918b1c9281dc125 Mon Sep 17 00:00:00 2001 From: Liang Wang Date: Sat, 8 Mar 2025 14:51:40 +0800 Subject: [PATCH 3/3] Fix TargetGroup Subs Issue (#77) --- action.yml | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 7d7b979..e3cea31 100644 --- a/action.yml +++ b/action.yml @@ -159,20 +159,39 @@ runs: # env: # AZURE_ENV_NAME: ${{ env.AZURE_ENV_NAME }} + - name: Check and Set targetScope in main.bicep + id: check_targetScope + if: ${{ inputs.validateAzd == 'true' }} + run: | + if [ -f "${{ steps.reform_path.outputs.workingDirectory }}/infra/main.bicep" ]; then + # Check if targetScope is set to 'subscription' or 'resourceGroup'. The sample sentence in bicep is: targetScope = 'subscription' + targetScope=$(grep -oP "targetScope\s*=\s*['\"]\K[^'\"]+" ${{ steps.reform_path.outputs.workingDirectory }}/infra/main.bicep) + echo "targetScope=$targetScope" >> $GITHUB_ENV + if [ "$targetScope" == "subscription" ]; then + echo "targetScope is set to 'subscription' in main.bicep" + # Add the targetScope to the env variables + elif [ "$targetScope" == "resourceGroup" ]; then + echo "targetScope is set to 'resourceGroup' in main.bicep" + else + echo "targetScope is not set to 'subscription' or 'resourceGroup' in main.bicep" + fi + fi + shell: bash + - name: Set azure resource group name in env id: set_resource_group - if: ${{ inputs.validateAzd == 'true' }} + if: ${{ inputs.validateAzd == 'true' && env.targetScope == 'resourceGroup' }} run: | azure_resource_group="rg-${{ env.AZURE_ENV_NAME }}" echo "AZURE_RESOURCE_GROUP=$azure_resource_group" >> $GITHUB_ENV - echo "AZURE_RESOURCE_GROUP is $AZURE_RESOURCE_GROUP" + echo "AZURE_RESOURCE_GROUP is $azure_resource_group" shell: bash env: AZURE_ENV_NAME: ${{ env.AZURE_ENV_NAME }} - name: Azure login uses: azure/login@v2 - if : ${{ inputs.validateAzd == 'true' }} + if : ${{ inputs.validateAzd == 'true' && env.targetScope == 'resourceGroup' }} with: client-id: ${{ env.AZURE_CLIENT_ID }} tenant-id: ${{ env.AZURE_TENANT_ID }} @@ -180,7 +199,7 @@ runs: - name: Azure CLI script id: create_resource_group - if : ${{ inputs.validateAzd == 'true' }} + if : ${{ inputs.validateAzd == 'true' && env.targetScope == 'resourceGroup' }} run: | az group create --resource-group ${{ env.AZURE_RESOURCE_GROUP }} --location ${{ env.AZURE_LOCATION }} shell: bash