-
Notifications
You must be signed in to change notification settings - Fork 2
40 lines (34 loc) · 1.53 KB
/
01-CreateAzureResources.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: 01-CreateAzureResources
on:
push:
paths:
- 'src/github-dashboard.iac/**'
workflow_dispatch:
env:
AZ_RG_NAME: 'rg-ghdashboard'
AZ_RG_LOCATION: 'centralus'
AZ_APP_NAME: 'ghdashboard'
AZ_SQL_NAME: 'ghdashboard'
AZ_SQL_USER: 'ghdashboard'
jobs:
bicep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login
uses: azure/login@v2
with:
creds: ${{ secrets.AZ_CREDENTIALS }}
- name: Create Azure Resournces
uses: azure/CLI@v2
with:
inlineScript: |
EXISTS=$(az group exists --name ${{ env.AZ_RG_NAME }})
if [ "$EXISTS" = "false" ]; then
echo "Resource Group ${{ env.AZ_RG_NAME }} does not exist. Creating..."
az group create --name ${{ env.AZ_RG_NAME }} --location ${{ env.AZ_RG_LOCATION }}
echo "Resource Group ${{ env.AZ_RG_NAME }} created."
else
echo "Resource Group ${{ env.AZ_RG_NAME }} already exists."
fi
az deployment group create --name gh-actions --resource-group ${{ env.AZ_RG_NAME }} --template-file src/github-dashboard.iac/main.bicep --parameters appServicePlanName=${{ env.AZ_APP_NAME }} webAppName=${{ env.AZ_APP_NAME }} storageName=${{ env.AZ_APP_NAME }} logAnalyticsName=${{ env.AZ_APP_NAME }} appInsightName=${{ env.AZ_APP_NAME }} functionName=${{ env.AZ_APP_NAME }} sqlserverName=${{ env.AZ_SQL_NAME }} sqlAdminLogin=${{ env.AZ_SQL_USER }} sqlAdminPassword=${{ secrets.AZ_SQL_PASSWORD }} --debug