2323# GitHub Actions workflow to deploy to Azure using azd
2424
2525permissions :
26+ actions : read # Needed for uploading SARIF reports
27+ security-events : write # Needed for uploading SARIF reports
2628 id-token : write
2729 contents : read
2830
@@ -37,23 +39,23 @@ jobs:
3739
3840 steps :
3941 - name : Checkout the branch ${{ github.ref_name }}
40- uses : actions/checkout@v4
42+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4143 with :
4244 ref : ${{ github.ref_name }}
4345
4446 - name : Install azd
45- uses : Azure/setup-azd@v2
47+ uses : Azure/setup-azd@ae0f8b5482eeac61e940f447327d84c73beb8b1e # v2.1.0
4648 with :
4749 version : ' 1.17.2' # Specify your desired azd version here
4850
4951 - name : Install Terraform
50- uses : hashicorp/setup-terraform@v3
52+ uses : hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
5153 with :
5254 terraform_version : 1.9.0
5355
5456
5557 - name : Install TFLint
56- uses : terraform-linters/setup-tflint@v4
58+ uses : terraform-linters/setup-tflint@90f302c255ef959cbfb4bd10581afecdb7ece3e6 # v4.1.1
5759 with :
5860 tflint_version : v0.49.0
5961 github_token : ${{ secrets.GITHUB_TOKEN }} # Used to avoid rate
@@ -68,84 +70,80 @@ jobs:
6870 gitleaks version
6971
7072 - name : Setup .NET SDK
71- uses : actions/setup-dotnet@v4
73+ uses : actions/setup-dotnet@55ec9447dda3d1cf6bd587150f3262f30ee10815 # v3.4.2
7274 with :
7375 dotnet-version : ' 8.0.x'
7476
77+ - name : Install Power Platform Tools
78+ uses : microsoft/powerplatform-actions/actions-install@51f663ea104eb227c3712215ceb2f82827d81c27 # v1.9.0
79+
7580 - name : Install Power Platform CLI
7681 run : |
77- dotnet tool install --global Microsoft.PowerApps.CLI.Tool
82+ dotnet tool install --global Microsoft.PowerApps.CLI.Tool --version 1.44.2
7883 pac help
7984
85+
8086 - name : Set Up Python
81- uses : actions/setup-python@v5
87+ uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # 5.6.0
8288 with :
8389 python-version : " 3.x"
8490
8591 - name : Install Checkov
8692 run : pip install checkov
8793
88-
8994 - name : Login to Azure with Federated Identity
90- uses : azure/login@v2
95+ uses : azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
9196 with :
9297 client-id : ${{ vars.AZURE_CLIENT_ID }}
9398 tenant-id : ${{ vars.AZURE_TENANT_ID }}
9499 subscription-id : ${{ vars.AZURE_SUBSCRIPTION_ID }}
95100
96101 - name : Provision Infrastructure
97102 env :
98- POWER_PLATFORM_USE_CLI : false
99- AZURE_SUBSCRIPTION_ID : ${{ vars.AZURE_SUBSCRIPTION_ID }}
100- RS_STORAGE_ACCOUNT : ${{ vars.RS_STORAGE_ACCOUNT }}
101- RS_CONTAINER_NAME : ${{ vars.RS_CONTAINER_NAME }}
102- RS_RESOURCE_GROUP : ${{ vars.RS_RESOURCE_GROUP }}
103- RESOURCE_SHARE_USER : ${{ vars.RESOURCE_SHARE_USER }}
103+ POWER_PLATFORM_USE_OIDC : " true"
104+ POWER_PLATFORM_CLIENT_ID : ${{ vars.AZURE_CLIENT_ID }}
105+ POWER_PLATFORM_TENANT_ID : ${{ vars.AZURE_TENANT_ID }}
106+
104107 ARM_USE_AZUREAD : " true"
105108 ARM_STORAGE_USE_AZUREAD : " true"
106109 ARM_USE_OIDC : " true"
107110 ARM_CLIENT_ID : ${{ vars.AZURE_CLIENT_ID }}
108111 ARM_TENANT_ID : ${{ vars.AZURE_TENANT_ID }}
109112 ARM_SUBSCRIPTION_ID : ${{ vars.AZURE_SUBSCRIPTION_ID }}
110- POWER_PLATFORM_CLIENT_ID : ${{ vars.AZURE_CLIENT_ID }}
111- POWER_PLATFORM_TENANT_ID : ${{ vars.AZURE_TENANT_ID }}
112- POWER_PLATFORM_USE_OIDC : " true"
113+ AZURE_SUBSCRIPTION_ID : ${{ vars.AZURE_SUBSCRIPTION_ID }}
114+
115+ RS_STORAGE_ACCOUNT : ${{ vars.RS_STORAGE_ACCOUNT }}
116+ RS_CONTAINER_NAME : ${{ vars.RS_CONTAINER_NAME }}
117+ RS_RESOURCE_GROUP : ${{ vars.RS_RESOURCE_GROUP }}
118+
119+ RESOURCE_SHARE_USER : ${{ vars.RESOURCE_SHARE_USER }}
120+
113121 GITHUB_PAT : ${{ secrets.MCS_RUNNER }}
114122 GITHUB_REPO_OWNER : ${{ github.repository_owner }}
115123 GITHUB_REPO_NAME : ${{ github.event.repository.name }}
116124 GITHUB_RUNNER_IMAGE_NAME : " github-runner"
117125 GITHUB_RUNNER_IMAGE_TAG : " latest"
118126 GITHUB_RUNNER_IMAGE_BRANCH : ${{ github.ref_name }}
119- shell : pwsh
127+ shell : bash
120128 run : |
121129 azd config set auth.useAzCliAuth "true"
122- azd env new $env:AZURE_ENV_NAME --location $env:AZURE_LOCATION --no-prompt
123- azd env set RESOURCE_SHARE_USER "$env:RESOURCE_SHARE_USER"
124- azd env set POWER_PLATFORM_USE_CLI "false"
125-
126- azd env set RS_STORAGE_ACCOUNT $env:RS_STORAGE_ACCOUNT
127- azd env set RS_CONTAINER_NAME $env:RS_CONTAINER_NAME
128- azd env set RS_RESOURCE_GROUP $env:RS_RESOURCE_GROUP
129-
130- azd env set GITHUB_PAT $env:GITHUB_PAT
131- azd env set GITHUB_REPO_OWNER $env:GITHUB_REPO_OWNER
132- azd env set GITHUB_REPO_NAME $env:GITHUB_REPO_NAME
133- azd env set GITHUB_RUNNER_IMAGE_NAME $env:GITHUB_RUNNER_IMAGE_NAME
134- azd env set GITHUB_RUNNER_IMAGE_TAG $env:GITHUB_RUNNER_IMAGE_TAG
135- azd env set GITHUB_RUNNER_IMAGE_BRANCH $env:GITHUB_RUNNER_IMAGE_BRANCH
130+ azd env new "$AZURE_ENV_NAME" --location "$AZURE_LOCATION" --no-prompt
131+ azd env set RESOURCE_SHARE_USER "$RESOURCE_SHARE_USER"
136132
133+ azd env set RS_STORAGE_ACCOUNT "$RS_STORAGE_ACCOUNT"
134+ azd env set RS_CONTAINER_NAME "$RS_CONTAINER_NAME"
135+ azd env set RS_RESOURCE_GROUP "$RS_RESOURCE_GROUP"
137136
138- azd env set GITHUB_PAT $env: GITHUB_PAT
139- azd env set GITHUB_REPO_OWNER $env: GITHUB_REPO_OWNER
140- azd env set GITHUB_REPO_NAME $env: GITHUB_REPO_NAME
141- azd env set GITHUB_RUNNER_IMAGE_NAME $env: GITHUB_RUNNER_IMAGE_NAME
142- azd env set GITHUB_RUNNER_IMAGE_TAG $env: GITHUB_RUNNER_IMAGE_TAG
143- azd env set GITHUB_RUNNER_IMAGE_BRANCH $env: GITHUB_RUNNER_IMAGE_BRANCH
137+ azd env set GITHUB_PAT "$ GITHUB_PAT"
138+ azd env set GITHUB_REPO_OWNER "$ GITHUB_REPO_OWNER"
139+ azd env set GITHUB_REPO_NAME "$ GITHUB_REPO_NAME"
140+ azd env set GITHUB_RUNNER_IMAGE_NAME "$ GITHUB_RUNNER_IMAGE_NAME"
141+ azd env set GITHUB_RUNNER_IMAGE_TAG "$ GITHUB_RUNNER_IMAGE_TAG"
142+ azd env set GITHUB_RUNNER_IMAGE_BRANCH "$ GITHUB_RUNNER_IMAGE_BRANCH"
144143
145144 azd provision --no-prompt
146145
147-
148- - uses : actions/upload-artifact@v4
146+ - uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
149147 if : success() || failure()
150148 with :
151149 name : sarif-reports
@@ -154,42 +152,42 @@ jobs:
154152 ./checkov-results.sarif/results_sarif.sarif
155153
156154 - name : Upload Gitleaks SARIF report to Github
157- uses : github/codeql-action/upload-sarif@v3
155+ uses : github/codeql-action/upload-sarif@9b02dc2f60288b463e7a66e39c78829b62780db7 # v2.22.1
158156 with :
159157 sarif_file : ./gitleaks-report.sarif
160158
161159
162160 - name : Upload Checkov SARIF Report to GitHub
163- uses : github/codeql-action/upload-sarif@v3
161+ uses : github/codeql-action/upload-sarif@9b02dc2f60288b463e7a66e39c78829b62780db7 # v2.22.1
164162 with :
165163 sarif_file : ./checkov-results.sarif/results_sarif.sarif
166164
167-
168165 - name : Azd down
169- if : ${{ github.event.inputs.run_azd_down == true }}
166+ if : ${{ github.event.inputs.run_azd_down == ' true' }}
170167 env :
171- POWER_PLATFORM_USE_CLI : false
172- AZURE_SUBSCRIPTION_ID : ${{ vars.AZURE_SUBSCRIPTION_ID }}
173- RS_STORAGE_ACCOUNT : ${{ vars.RS_STORAGE_ACCOUNT }}
174- RS_CONTAINER_NAME : ${{ vars.RS_CONTAINER_NAME }}
175- RS_RESOURCE_GROUP : ${{ vars.RS_RESOURCE_GROUP }}
176- RESOURCE_SHARE_USER : ${{ vars.RESOURCE_SHARE_USER }}
168+ POWER_PLATFORM_CLIENT_ID : ${{ vars.AZURE_CLIENT_ID }}
169+ POWER_PLATFORM_TENANT_ID : ${{ vars.AZURE_TENANT_ID }}
170+ POWER_PLATFORM_USE_OIDC : " true"
171+
177172 ARM_USE_AZUREAD : " true"
178173 ARM_STORAGE_USE_AZUREAD : " true"
179174 ARM_USE_OIDC : " true"
180175 ARM_CLIENT_ID : ${{ vars.AZURE_CLIENT_ID }}
181176 ARM_TENANT_ID : ${{ vars.AZURE_TENANT_ID }}
182177 ARM_SUBSCRIPTION_ID : ${{ vars.AZURE_SUBSCRIPTION_ID }}
183- POWER_PLATFORM_CLIENT_ID : ${{ vars.AZURE_CLIENT_ID }}
184- POWER_PLATFORM_TENANT_ID : ${{ vars.AZURE_TENANT_ID }}
185- POWER_PLATFORM_USE_OIDC : " true"
186- shell : pwsh
187- run : |
178+ AZURE_SUBSCRIPTION_ID : ${{ vars.AZURE_SUBSCRIPTION_ID }}
188179
189- azd env set RS_STORAGE_ACCOUNT $env:RS_STORAGE_ACCOUNT
190- azd env set RS_CONTAINER_NAME $env:RS_CONTAINER_NAME
191- azd env set RS_RESOURCE_GROUP $env:RS_RESOURCE_GROUP
192- azd env set RESOURCE_SHARE_USER "$env:RESOURCE_SHARE_USER"
180+ RS_STORAGE_ACCOUNT : ${{ vars.RS_STORAGE_ACCOUNT }}
181+ RS_CONTAINER_NAME : ${{ vars.RS_CONTAINER_NAME }}
182+ RS_RESOURCE_GROUP : ${{ vars.RS_RESOURCE_GROUP }}
183+ RESOURCE_SHARE_USER : ${{ vars.RESOURCE_SHARE_USER }}
184+
185+ shell : bash
186+ run : |
187+ azd env set RS_STORAGE_ACCOUNT "$RS_STORAGE_ACCOUNT"
188+ azd env set RS_CONTAINER_NAME "$RS_CONTAINER_NAME"
189+ azd env set RS_RESOURCE_GROUP "$RS_RESOURCE_GROUP"
190+ azd env set RESOURCE_SHARE_USER "$RESOURCE_SHARE_USER"
193191
194- azd env select $env: AZURE_ENV_NAME
192+ azd env select "$ AZURE_ENV_NAME"
195193 azd down --no-prompt --force --purge
0 commit comments