Skip to content

Commit 7a7d77a

Browse files
committed
Enhance Azure deployment workflow with staging and production environments
1 parent fc045f3 commit 7a7d77a

File tree

1 file changed

+60
-2
lines changed

1 file changed

+60
-2
lines changed

.github/workflows/azure-deploy.yml

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
paths:
88
- 'generate-url-shortene/infrastructure/**'
99
pull_request:
10+
branches:
11+
- main
1012
paths:
1113
- 'generate-url-shortene/infrastructure/**'
1214
workflow_dispatch: # Allows you to run the workflow manually
@@ -18,7 +20,63 @@ permissions:
1820
jobs:
1921
deploy-dev:
2022
runs-on: ubuntu-latest
21-
environment: development
23+
environment: Development
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Azure Login
28+
uses: azure/[email protected]
29+
with:
30+
creds: ${{ secrets.AZURE_CREDENTIALS }}
31+
32+
- uses: azure/[email protected]
33+
with:
34+
inlineScript: |
35+
#!/bin/bash
36+
az group create --name ${{ vars.RESOURCE_GROUP_NAME }} --location ${{ vars.RESOURCE_GROUP_LOCATION }}
37+
echo "Resource Group Created"
38+
39+
- name: Deploy Bicep Template
40+
uses: azure/arm-deploy@v2
41+
with:
42+
scope: resourcegroup
43+
resourceGroupName: ${{ vars.RESOURCE_GROUP_NAME }}
44+
template: ./infrastructure/main.bicep
45+
failOnStdErr: true
46+
47+
deploy-stg:
48+
runs-on: ubuntu-latest
49+
needs: deploy-dev
50+
environment: Staging
51+
steps:
52+
- uses: actions/checkout@v4
53+
54+
- name: Azure Login
55+
uses: azure/[email protected]
56+
with:
57+
creds: ${{ secrets.AZURE_CREDENTIALS }}
58+
59+
- uses: azure/[email protected]
60+
with:
61+
inlineScript: |
62+
#!/bin/bash
63+
az group create --name ${{ vars.RESOURCE_GROUP_NAME }} --location ${{ vars.RESOURCE_GROUP_LOCATION }}
64+
echo "Resource Group Created"
65+
66+
- name: Deploy Bicep Template
67+
uses: azure/arm-deploy@v2
68+
with:
69+
scope: resourcegroup
70+
resourceGroupName: ${{ vars.RESOURCE_GROUP_NAME }}
71+
template: ./infrastructure/main.bicep
72+
failOnStdErr: true
73+
74+
deploy-prod:
75+
76+
runs-on: ubuntu-latest
77+
needs: deploy-stg
78+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
79+
environment: Production
2280
steps:
2381
- uses: actions/checkout@v4
2482

@@ -40,4 +98,4 @@ jobs:
4098
scope: resourcegroup
4199
resourceGroupName: ${{ vars.RESOURCE_GROUP_NAME }}
42100
template: ./infrastructure/main.bicep
43-
failOnStdErr: true
101+
failOnStdErr: true

0 commit comments

Comments
 (0)