File tree 6 files changed +205
-0
lines changed
6 files changed +205
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Deploy Static Website
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - main
7
+ workflow_dispatch :
8
+
9
+ permissions :
10
+ id-token : write
11
+ contents : read
12
+
13
+ jobs :
14
+ deploy :
15
+ runs-on : ubuntu-latest
16
+ steps :
17
+ - uses : actions/checkout@v4
18
+
19
+ - name : Azure Login
20
+ uses : azure/login@v1
21
+ with :
22
+ client-id : ${{ secrets.AZURE_CLIENT_ID }}
23
+ tenant-id : ${{ secrets.AZURE_TENANT_ID }}
24
+ subscription-id : ${{ secrets.AZURE_SUBSCRIPTION_ID }}
25
+
26
+ - name : Setup Terraform
27
+ uses : hashicorp/setup-terraform@v3
28
+ with :
29
+ terraform_version : " 1.7.0"
30
+
31
+ - name : Terraform Init
32
+ run : terraform init
33
+ working-directory : ./terraform
34
+
35
+ - name : Terraform Plan
36
+ run : terraform plan
37
+ working-directory : ./terraform
38
+ env :
39
+ TF_VAR_environment : " prod"
40
+
41
+ - name : Terraform Apply
42
+ run : terraform apply -auto-approve
43
+ working-directory : ./terraform
44
+ env :
45
+ TF_VAR_environment : " prod"
46
+
47
+ - name : Get Storage Account Name
48
+ id : storage
49
+ run : |
50
+ STORAGE_ACCOUNT=$(terraform output -raw storage_account_name)
51
+ echo "storage_account=$STORAGE_ACCOUNT" >> $GITHUB_OUTPUT
52
+ working-directory : ./terraform
53
+
54
+ - name : Upload HTML files
55
+ run : |
56
+ az storage blob upload-batch \
57
+ --account-name ${{ steps.storage.outputs.storage_account }} \
58
+ --auth-mode login \
59
+ --source ./html \
60
+ --destination '$web' \
61
+ --overwrite true
Original file line number Diff line number Diff line change
1
+ # Terraform ignores
2
+ ** /.terraform /*
3
+ * .tfstate
4
+ * .tfstate. *
5
+ crash.log
6
+ crash. * .log
7
+ * .tfvars
8
+ * .tfvars.json
9
+ override.tf
10
+ override.tf.json
11
+ * _override.tf
12
+ * _override.tf.json
13
+ .terraformrc
14
+ terraform.rc
15
+ .terraform.lock.hcl
16
+
17
+ # Node.js ignores
18
+ node_modules /
19
+ npm-debug.log *
20
+ yarn-debug.log *
21
+ yarn-error.log *
22
+ .pnpm-debug.log *
23
+ .env
24
+ .env.development.local
25
+ .env.test.local
26
+ .env.production.local
27
+ .env.local
28
+ coverage /
29
+ .next /
30
+ out /
31
+ build /
32
+ dist /
33
+ .DS_Store
34
+ * .pem
35
+ .npm
36
+ .eslintcache
37
+ .node_repl_history
38
+ * .tgz
39
+ .yarn-integrity
40
+ .idea /
41
+ .vscode /
42
+ * .swp
43
+ * .swo
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+ < title > 404 - Page Not Found</ title >
7
+ < style >
8
+ body {
9
+ margin : 0 ;
10
+ padding : 0 ;
11
+ font-family : Arial, sans-serif;
12
+ background-color : # f5f5f5 ;
13
+ color : # 333 ;
14
+ line-height : 1.6 ;
15
+ }
16
+
17
+ .error-container {
18
+ max-width : 600px ;
19
+ margin : 100px auto;
20
+ text-align : center;
21
+ padding : 20px ;
22
+ }
23
+
24
+ .error-code {
25
+ font-size : 120px ;
26
+ color : # e74c3c ;
27
+ font-weight : bold;
28
+ margin : 0 ;
29
+ }
30
+
31
+ .error-message {
32
+ font-size : 24px ;
33
+ margin : 20px 0 ;
34
+ }
35
+
36
+ .home-button {
37
+ display : inline-block;
38
+ padding : 12px 24px ;
39
+ background-color : # 3498db ;
40
+ color : white;
41
+ text-decoration : none;
42
+ border-radius : 4px ;
43
+ margin-top : 20px ;
44
+ transition : background-color 0.3s ;
45
+ }
46
+
47
+ .home-button : hover {
48
+ background-color : # 2980b9 ;
49
+ }
50
+ </ style >
51
+ </ head >
52
+ < body >
53
+ < div class ="error-container ">
54
+ < div class ="error-code "> 404</ div >
55
+ < div class ="error-message "> Oops! Page Not Found</ div >
56
+ < p > The page you're looking for doesn't exist or has been moved.</ p >
57
+ < a href ="/ " class ="home-button "> Return to Home</ a >
58
+ </ div >
59
+ </ body >
60
+ </ html >
Original file line number Diff line number Diff line change
1
+ terraform {
2
+ required_providers {
3
+ azurerm = {
4
+ source = " hashicorp/azurerm"
5
+ version = " ~> 3.0"
6
+ }
7
+ }
8
+ }
9
+
10
+ provider "azurerm" {
11
+ features {}
12
+ }
Original file line number Diff line number Diff line change
1
+ resource "azurerm_resource_group" "main" {
2
+ name = " calculators-and-converters"
3
+ location = " Central India" # Change this to your preferred region
4
+
5
+ tags = {
6
+ environment = " production"
7
+ }
8
+ }
Original file line number Diff line number Diff line change
1
+ resource "azurerm_storage_account" "static_web" {
2
+ name = " calculatorsandconverters" # Must be globally unique
3
+ resource_group_name = azurerm_resource_group. main . name
4
+ location = azurerm_resource_group. main . location
5
+ account_tier = " Standard"
6
+ account_replication_type = " LRS"
7
+
8
+ static_website {
9
+ index_document = " xirr.html"
10
+ error_404_document = " 404.html"
11
+ }
12
+ }
13
+
14
+ # Output the static website URL
15
+ output "static_website_url" {
16
+ value = azurerm_storage_account. static_web . primary_web_endpoint
17
+ }
18
+
19
+ output "storage_account_name" {
20
+ value = azurerm_storage_account. static_web . name
21
+ }
You can’t perform that action at this time.
0 commit comments