Skip to content

Commit a99e1e3

Browse files
committed
Add Azure deployment workflow for infrastructure using Bicep templates
1 parent bf861f0 commit a99e1e3

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

.github/workflows/azure-deploy.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Azure Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
paths:
9+
- 'generate-url-shortene/infrastructure/**'
10+
pull_request:
11+
paths:
12+
- 'generate-url-shortene/infrastructure/**'
13+
workflow_dispatch: # Allows you to run the workflow manually
14+
15+
permissions:
16+
contents: read
17+
pull-requests: write
18+
19+
jobs:
20+
deploy-dev:
21+
runs-on: ubuntu-latest
22+
environment: development
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Azure Login
27+
uses: azure/[email protected]
28+
with:
29+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
30+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
31+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
32+
33+
- uses: Azure/CLI@v2
34+
with:
35+
inlineScript: |
36+
#!/bin/bash
37+
az group create --name ${{ vars.RESOURCE_GROUP_NAME }} --location ${{ vars.RESOURCE_GROUP_LOCATION }}
38+
echo "Resource Group Created"
39+
40+
- name: Deploy
41+
uses: azure/arm-deploy@v2
42+
with:
43+
scope: 'Resource Group'
44+
resourceGroupName: ${{ vars.RESOURCE_GROUP_NAME }}
45+
template: generate-url-shortene/infrastructure/main.bicep

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,20 @@ az login
1515
```bash
1616
az group create --name rg-urlshortener-dev --location EastAsia
1717
```
18+
19+
### Create User for GH Actions
20+
21+
```bash
22+
az ad sp create-for-rbac --name "Github-Actions-SP" \
23+
--role contributor \
24+
--scopes /subscriptions/c49b5a1a-e3a7-485b-b6e3-84dbafe30ebd \
25+
--sdk-auth
26+
27+
```
28+
29+
```powershell
30+
az ad sp create-for-rbac --name "Github-Actions-SP" `
31+
--role contributor `
32+
--scopes /subscriptions/c49b5a1a-e3a7-485b-b6e3-84dbafe30ebd `
33+
--sdk-auth
34+
```

0 commit comments

Comments
 (0)