Skip to content

Commit

Permalink
ci(webap): deploy to web app
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucile Jeanneret committed Dec 17, 2024
1 parent 76ade12 commit 3d516b6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 92 deletions.
65 changes: 0 additions & 65 deletions .github/workflows/main_virtual-teacher-webapp-wus.yml

This file was deleted.

32 changes: 29 additions & 3 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,32 @@ jobs:
uses: Azure/get-keyvault-secrets@v1
with:
keyvault: "kvvirtualteacher"
secrets: 'subscription-id' # comma separated list of secret keys that need to be fetched from the Key Vault
- run : echo ${{ steps.keyvault.outputs.subscription-id }}

secrets: 'subscription-id, appService-clientId, appService-clientSecret' # comma separated list of secret keys that need to be fetched from the Key Vault

- name: Set up Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.0.11

- name: Initialize Terraform
run: terraform init
working-directory: ./deploy

- name: Apply Terraform
run: terraform apply -auto-approve
working-directory: ./deploy

- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ steps.keyvault.outputs.appService-clientId }}
tenant-id: ${{ steps.keyvault.outputs.appService-tenantId }}
subscription-id: ${{ steps.keyvault.outputs.subscription-id }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'virtual-teacher-webapp-wus'
slot-name: 'Production'
package: .
44 changes: 20 additions & 24 deletions deploy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,28 @@ provider "azurerm" {
data "azurerm_resource_group" "rg" {
name = "rg-virtual-teacher-demo-wus"
}
# Create the Linux App Service Plan
resource "azurerm_service_plan" "appserviceplan" {
name = "webapp-asp-${random_integer.ri.result}"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
os_type = "Linux"
sku_name = "B1"

# Reference to an existing App Service Plan
data "azurerm_app_service_plan" "existing_plan" {
name = "ASP-rgvirtualteacherdemowus-8ff3"
resource_group_name = data.azurerm_resource_group.rg.name
}

# Create the web app, pass in the App Service Plan ID
resource "azurerm_linux_web_app" "webapp" {
name = "webapp-${random_integer.ri.result}"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
service_plan_id = azurerm_service_plan.appserviceplan.id
https_only = true
site_config {
minimum_tls_version = "1.2"
}
# Reference to an existing App Service (Web App)
data "azurerm_app_service" "existing_webapp" {
name = "webapp-virtual-teacher"
resource_group_name = data.azurerm_resource_group.rg.name
}

# Deploy code from a public GitHub repo
resource "azurerm_app_service_source_control" "sourcecontrol" {
app_id = azurerm_linux_web_app.webapp.id
repo_url = "https://github.com/Azure-Samples/nodejs-docs-hello-world"
branch = "master"
use_manual_integration = true
use_mercurial = false
# Deploy code to the existing Web App
resource "azurerm_app_service_slot" "deployment_slot" {
name = "staging"
location = data.azurerm_resource_group.rg.location
resource_group_name = data.azurerm_resource_group.rg.name
app_service_plan_id = data.azurerm_app_service_plan.existing_plan.id
app_service_name = data.azurerm_app_service.existing_webapp.name

site_config {
scm_type = "LocalGit"
}
}

0 comments on commit 3d516b6

Please sign in to comment.