Skip to content

Commit 21f8527

Browse files
authored
chore: tf gh actions (#35)
* chore: tf gh actions * chore: experiment * chore: update * chore: gh action * chore: update * chore: update * chore: update * chore: add tf to hg * chore: update * fix: fmt * fix: ci * chore: trigger * chore: trigger * fix: ci * chore: tf state * chore: update
1 parent 0d0892d commit 21f8527

File tree

11 files changed

+2407
-284
lines changed

11 files changed

+2407
-284
lines changed

.github/workflows/build.yml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
name: Build evently
55

66
on:
7-
push:
8-
branches: [ "main" ]
97
pull_request:
108
branches: [ "main" ]
119

10+
# important for azure/login
11+
permissions:
12+
id-token: write
13+
contents: read
14+
1215
jobs:
1316
build:
1417
runs-on: ubuntu-latest
@@ -34,4 +37,33 @@ jobs:
3437
- name: Run UI Tests
3538
run: cd src/evently.client && pnpm run test
3639
- name: Test Docker Image
37-
run: docker build --tag=expo-connect/latest --file=src/Evently.Server/Dockerfile .
40+
run: docker build --tag=expo-connect/latest --file=src/Evently.Server/Dockerfile .
41+
42+
validate-tf:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- name: Azure Login
47+
uses: azure/login@v2
48+
with:
49+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
50+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
51+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
52+
- name: Validate Azure CLI can be used
53+
uses: azure/cli@v2
54+
with:
55+
azcliversion: latest
56+
inlineScript: |
57+
az account show
58+
- name: Set up Terraform
59+
uses: hashicorp/setup-terraform@v3
60+
- name: Terraform init
61+
run: |
62+
cd deploy/Terraform
63+
terraform init
64+
- name: Terraform validate
65+
run: |
66+
cd deploy/Terraform
67+
terraform validate
68+
69+

.github/workflows/deploy.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Deploy evently
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
7+
# important for azure/login
8+
permissions:
9+
id-token: write
10+
contents: read
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Azure Login
19+
uses: azure/login@v2
20+
with:
21+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
22+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
23+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
24+
- name: Validate Azure CLI can be used
25+
uses: azure/cli@v2
26+
with:
27+
azcliversion: latest
28+
inlineScript: |
29+
az account show
30+
- name: Set up Terraform
31+
uses: hashicorp/setup-terraform@v3
32+
- name: Terraform init
33+
run: |
34+
cd deploy/Terraform
35+
terraform init
36+
- name: Terraform validate
37+
run: |
38+
cd deploy/Terraform
39+
terraform validate
40+
- name: Terraform plan
41+
run: |
42+
cd deploy/Terraform
43+
terraform plan
44+
env:
45+
TF_VAR_sql_admin_username: ${{ secrets.TF_VAR_SQL_ADMIN_USERNAME }}
46+
TF_VAR_sql_admin_password: ${{ secrets.TF_VAR_SQL_ADMIN_PASSWORD }}
47+
TF_VAR_google_client_id: ${{ secrets.TF_VAR_GOOGLE_CLIENT_ID }}
48+
TF_VAR_google_client_secret: ${{ secrets.TF_VAR_GOOGLE_CLIENT_SECRET }}
49+
TF_VAR_email_from: ${{ secrets.TF_VAR_EMAIL_FROM }}
50+
TF_VAR_smtp_password: ${{ secrets.TF_VAR_SMTP_PASSWORD }}
51+
# Apply step can be skipped for pull requests
52+
- name: Terraform apply
53+
run: cd deploy/Terraform && terraform apply -auto-approve
54+
env:
55+
TF_VAR_sql_admin_username: ${{ secrets.TF_VAR_SQL_ADMIN_USERNAME }}
56+
TF_VAR_sql_admin_password: ${{ secrets.TF_VAR_SQL_ADMIN_PASSWORD }}
57+
TF_VAR_google_client_id: ${{ secrets.TF_VAR_GOOGLE_CLIENT_ID }}
58+
TF_VAR_google_client_secret: ${{ secrets.TF_VAR_GOOGLE_CLIENT_SECRET }}
59+
TF_VAR_email_from: ${{ secrets.TF_VAR_EMAIL_FROM }}
60+
TF_VAR_smtp_password: ${{ secrets.TF_VAR_SMTP_PASSWORD }}
61+

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,6 @@ src/emailpaywall.client/.svelte-kit
437437
**/obj/
438438

439439
# Terraform
440-
**/*.tfstate
441-
**/*.tfstate.*
442440
**/*.tfvars
443441
**/*.tfvars.json
444442
**/.terraform/

deploy/Terraform/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ terraform {
1212
}
1313

1414
locals {
15-
environment = "staging"
15+
environment = "staging"
1616
}
1717

1818
provider "azurerm" {

deploy/Terraform/sql-database.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ resource "azurerm_mssql_database" "db" {
1616
server_id = azurerm_mssql_server.sql_server.id
1717
sku_name = "Basic" # Cheapest option: 5 DTUs
1818
max_size_gb = 2 # Minimum size for Basic tier
19-
auto_pause_delay_in_minutes = 60 # Auto-pause after 1 hour of inactivity
19+
auto_pause_delay_in_minutes = 60 # Auto-pause after 1 hour of inactivity
2020
}
2121

2222
resource "azurerm_mssql_firewall_rule" "allow_azure_services" {

0 commit comments

Comments
 (0)