-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.sh
executable file
·43 lines (35 loc) · 1.24 KB
/
deploy.sh
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
41
42
43
#!/bin/bash
location="northeurope"
resourceGroupName="githubdemos"
uamiName="github-uami"
keyvaultName="chgeuergithub2"
secretName="demosecret"
secretValue="Greetings from Bicep"
githubOrgOrUser="chgeuer"
githubRepo="github-action-via-user-assigned-managed-identity-to-keyvault-secret"
githubBranch="main"
az group create --location "${location}" --name "${resourceGroupName}"
az deployment group create \
--resource-group "${resourceGroupName}" \
--template-file keyvault.bicep \
--parameters \
location="${location}" \
githubOrgOrUser="${githubOrgOrUser}" \
githubRepo="${githubRepo}" \
githubBranch="${githubBranch}" \
keyvaultName="${keyvaultName}" \
uamiName="${uamiName}" \
secretName="${secretName}" \
secretValue="${secretValue}"
identityValues="$( az identity show \
--resource-group "${resourceGroupName}" \
--name "${uamiName}" )"
tenantId="$( echo "${identityValues}" | jq -r '.tenantId' )"
uamiClientId="$( echo "${identityValues}" | jq -r '.clientId' )"
cat <<EOF > env.txt
AZURE_TENANT_ID=${tenantId}
AZURE_UAMI_CLIENT_ID=${uamiClientId}
AZURE_KEYVAULT_NAME=${keyvaultName}
AZURE_KEYVAULT_SECRET_NAME=${secretName}
EOF
# gh secret set --repo "${githubOrgOrUser}/${githubRepo}" --env-file env.txt