Skip to content

Commit f8723d9

Browse files
committed
Updated Workflow Letest
1 parent 40210e5 commit f8723d9

File tree

3 files changed

+16
-41
lines changed

3 files changed

+16
-41
lines changed

.github/workflows/build-deploy.yml

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,31 @@ jobs:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
###############################################################
1716
# Checkout Repository
18-
###############################################################
17+
1918
- name: Checkout repository
2019
uses: actions/checkout@v4
2120

22-
###############################################################
2321
# Configure Git (for Terraform modules hosted on GitHub)
24-
###############################################################
22+
2523
- name: Configure Git for Terraform module downloads
2624
run: |
2725
git config --global url."https://${{ secrets.GH_TOKEN }}:x-oauth-basic@github.com/".insteadOf "https://github.com/"
2826
29-
###############################################################
3027
# Login to Azure
31-
###############################################################
28+
3229
- name: Azure Login
3330
uses: azure/login@v2
3431
with:
3532
creds: ${{ secrets.AZURE_CREDENTIALS }}
3633

37-
###############################################################
3834
# Login to Azure Container Registry
39-
###############################################################
35+
4036
- name: Log in to ACR
4137
run: az acr login --name ${{ secrets.ACR_NAME }}
4238

43-
###############################################################
4439
# Determine Deployment Slot (Blue or Green)
45-
###############################################################
40+
4641
- name: Determine Deployment Slot (Blue/Green)
4742
id: slot
4843
run: |
@@ -60,9 +55,8 @@ jobs:
6055
echo $NEW_SLOT > $LAST_SLOT_FILE
6156
echo "slot=$NEW_SLOT" >> $GITHUB_OUTPUT
6257
63-
###############################################################
6458
# Build & Push Docker Image to ACR
65-
###############################################################
59+
6660
- name: Build and Push Docker image
6761
run: |
6862
IMAGE_TAG=${{ github.run_number }}
@@ -71,18 +65,15 @@ jobs:
7165
--image ${{ env.IMAGE_NAME }}:${IMAGE_TAG} \
7266
--image ${{ env.IMAGE_NAME }}:${{ steps.slot.outputs.slot }} \
7367
.
74-
75-
###############################################################
7668
# Setup Terraform
77-
###############################################################
69+
7870
- name: Setup Terraform
7971
uses: hashicorp/setup-terraform@v3
8072
with:
8173
terraform_version: 1.9.5
8274

83-
###############################################################
8475
# Terraform Init
85-
###############################################################
76+
8677
- name: Terraform Init
8778
working-directory: ${{ env.TF_DIR }}
8879
env:
@@ -92,9 +83,8 @@ jobs:
9283
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
9384
run: terraform init -input=false
9485

95-
###############################################################
9686
# Terraform Plan
97-
###############################################################
87+
9888
- name: Terraform Plan
9989
working-directory: ${{ env.TF_DIR }}
10090
env:
@@ -110,9 +100,8 @@ jobs:
110100
-var="image_tag=${{ github.run_number }}" \
111101
-out=tfplan
112102
113-
###############################################################
114103
# Terraform Apply (Deploy Selected Slot)
115-
###############################################################
104+
116105
- name: Terraform Apply
117106
working-directory: ${{ env.TF_DIR }}
118107
env:
@@ -122,9 +111,8 @@ jobs:
122111
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
123112
run: terraform apply -auto-approve tfplan
124113

125-
###############################################################
126114
# Optional: Swap Slots (Green <-> Blue)
127-
###############################################################
115+
128116
- name: Swap Slots (Post Deployment)
129117
if: success()
130118
working-directory: ${{ env.TF_DIR }}

terraformv3/examples/complete/container_platform/example.tf

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
###############################################################
21
# Provider
3-
###############################################################
2+
43
provider "azurerm" {
54
features {}
65
}
76

8-
###############################################################
97
# Local declaration
10-
###############################################################
8+
119
locals {
1210
name = "ayush-test"
1311
environment = "dev"
1412
label_order = ["name", "environment"]
1513
location = "Canada Central"
1614
}
1715

18-
###############################################################
1916
# Resource Group
20-
###############################################################
17+
2118
module "resource_group" {
2219
source = "clouddrove/resource-group/azure"
2320
version = "1.0.2"
@@ -27,9 +24,8 @@ module "resource_group" {
2724
location = local.location
2825
}
2926

30-
###############################################################
3127
# Log Analytics
32-
###############################################################
28+
3329
module "log-analytics" {
3430
source = "clouddrove/log-analytics/azure"
3531
version = "1.1.0"
@@ -43,9 +39,8 @@ module "log-analytics" {
4339
log_analytics_workspace_id = module.log-analytics.workspace_id
4440
}
4541

46-
###############################################################
4742
# Primary App Service (Production Slot)
48-
###############################################################
43+
4944
module "app-container" {
5045
source = "../../.."
5146
name = local.name
@@ -86,9 +81,7 @@ module "app-container" {
8681
log_analytics_workspace_id = module.log-analytics.workspace_id
8782
}
8883

89-
###############################################################
9084
# Blue-Green Deployment Configuration
91-
###############################################################
9285

9386
# --- Blue Slot (Active Production) ---
9487
resource "azurerm_linux_web_app_slot" "blue" {
@@ -130,11 +123,7 @@ resource "azurerm_linux_web_app_slot" "green" {
130123
}
131124
}
132125

133-
###############################################################
134126
# Optional: Blue-Green Swap (Manual or Pipeline Triggered)
135-
###############################################################
136-
# This resource defines slot swap (to switch traffic)
137-
# You can trigger it manually or via CI/CD (e.g., GitHub Actions)
138127

139128
resource "azurerm_web_app_slot_swap" "swap" {
140129
resource_group_name = module.resource_group.resource_group_name

terraformv3/examples/complete/container_platform/versions.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
###############################################################
21
# Variables
3-
###############################################################
42

53
variable "slot_name" {
64
description = "Slot name"

0 commit comments

Comments
 (0)