changing api to azure function app
This commit is contained in:
36
.github/workflows/api.yaml
vendored
Normal file
36
.github/workflows/api.yaml
vendored
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
name: 'API Build and Deploy'
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
calling_workflow:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: ${{ inputs.calling_workflow }}
|
||||||
|
steps:
|
||||||
|
- name: 'Checkout'
|
||||||
|
uses: action/checkout@v4
|
||||||
|
|
||||||
|
- name: 'Setup Node'
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ vars.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: |
|
||||||
|
npm install
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
npm run build -w api
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
uses: Azure/functions-action@v1
|
||||||
|
with:
|
||||||
|
app-name: ${{ vars.API_FUNCTION_APP_NAME }}
|
||||||
|
package: ${{ vars.API_FUNCTION_APP_PACKAGE_PATH }}
|
||||||
|
publish-profile: ${{ secrets.API_FUNCTION_APP_PUBLISH_PROFILE }}
|
||||||
47
.github/workflows/app.yaml
vendored
Normal file
47
.github/workflows/app.yaml
vendored
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
name: 'App Build and Deploy'
|
||||||
|
on:
|
||||||
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
calling_workflow:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
deployment_environment:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: ${{ inputs.calling_workflow }}
|
||||||
|
env:
|
||||||
|
VITE_CLIENT_ID: ${{ secrets.VITE_CLIENT_ID }}
|
||||||
|
VITE_TENANT_ID: ${{ secrets.VITE_TENANT_ID }}
|
||||||
|
VITE_REDIRECT_URL: ${{ secrets.VITE_REDIRECT_URL }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: 'Setup Node'
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: ${{ vars.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: |
|
||||||
|
npm install
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: |
|
||||||
|
npm run build -w app
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
id: builddeploy
|
||||||
|
uses: Azure/static-web-apps-deploy@v1
|
||||||
|
with:
|
||||||
|
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
|
||||||
|
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
action: 'upload'
|
||||||
|
skip_app_build: true
|
||||||
|
app_location: ${{ vars.APP_LOCATION }}
|
||||||
|
deployment_environment: ${{ inputs.deployment_environment }}
|
||||||
21
.github/workflows/dev.yaml
vendored
Normal file
21
.github/workflows/dev.yaml
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
name: Dev
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- feature/**
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-deploy-api:
|
||||||
|
name: build-deploy-api
|
||||||
|
uses: ./.github/workflows/api.yaml
|
||||||
|
with:
|
||||||
|
calling_workflow: dev
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
build-deploy-app:
|
||||||
|
name: build-deploy-app
|
||||||
|
uses: ./.github/workflows/app.yaml
|
||||||
|
with:
|
||||||
|
calling_workflow: dev
|
||||||
|
deployment_environment: development
|
||||||
|
secrets: inherit
|
||||||
43
.github/workflows/feature.yml
vendored
43
.github/workflows/feature.yml
vendored
@@ -1,43 +0,0 @@
|
|||||||
name: Feature
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- feature/**
|
|
||||||
|
|
||||||
env:
|
|
||||||
VITE_CLIENT_ID: ${{ vars.VITE_CLIENT_ID }}
|
|
||||||
VITE_TENANT_ID: ${{ vars.VITE_TENANT_ID }}
|
|
||||||
VITE_REDIRECT_URL: ${{ vars.VITE_REDIRECT_URL }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build_and_deploy_job:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Build and Deploy Job
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
|
|
||||||
- name: Install
|
|
||||||
run: |
|
|
||||||
npm install
|
|
||||||
|
|
||||||
- name: Build API
|
|
||||||
run: |
|
|
||||||
npm run build -w api
|
|
||||||
|
|
||||||
- name: Build and Deploy
|
|
||||||
id: builddeploy
|
|
||||||
uses: Azure/static-web-apps-deploy@v1
|
|
||||||
with:
|
|
||||||
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
|
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
action: 'upload'
|
|
||||||
app_build_command: ${{ vars.APP_BUILD_COMMAND }}
|
|
||||||
app_location: ${{ vars.APP_LOCATION }}
|
|
||||||
# api_build_command: ${{ vars.API_BUILD_COMMAND }}
|
|
||||||
api_location: ${{ vars.API_LOCATION }}
|
|
||||||
output_location: ${{ vars.OUTPUT_LOCATION }}
|
|
||||||
deployment_environment: 'development'
|
|
||||||
skip_api_build: true
|
|
||||||
37
.github/workflows/pull_request.yaml
vendored
Normal file
37
.github/workflows/pull_request.yaml
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
name: Pull Request
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened, closed]
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-deploy-api:
|
||||||
|
if: github.event_name == 'pull_request' && github.event.action != 'closed'
|
||||||
|
name: build-deploy-api
|
||||||
|
uses: ./.github/workflows/api.yaml
|
||||||
|
with:
|
||||||
|
calling_workflow: dev
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
build-deploy-app:
|
||||||
|
if: github.event_name == 'pull_request' && github.event.action != 'closed'
|
||||||
|
name: build-deploy-app
|
||||||
|
uses: ./.github/workflows/app.yaml
|
||||||
|
with:
|
||||||
|
calling_workflow: dev
|
||||||
|
deployment_environment: staging
|
||||||
|
secrets: inherit
|
||||||
|
|
||||||
|
close-pull-request-job:
|
||||||
|
if: github.event_name == 'pull_request' && github.event.action == 'closed'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Close Pull Request Job
|
||||||
|
steps:
|
||||||
|
- name: Close Pull Request
|
||||||
|
id: closepullrequest
|
||||||
|
uses: Azure/static-web-apps-deploy@v1
|
||||||
|
with:
|
||||||
|
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
|
||||||
|
action: 'close'
|
||||||
43
.github/workflows/pull_request.yml
vendored
43
.github/workflows/pull_request.yml
vendored
@@ -1,43 +0,0 @@
|
|||||||
name: Pull Request
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [opened, synchronize, reopened, closed]
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build_and_deploy_job:
|
|
||||||
if: github.event_name == 'pull_request' && github.event.action != 'closed'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Build and Deploy Job
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
lfs: false
|
|
||||||
- name: Build And Deploy
|
|
||||||
id: builddeploy
|
|
||||||
uses: Azure/static-web-apps-deploy@v1
|
|
||||||
with:
|
|
||||||
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
|
|
||||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
action: 'upload'
|
|
||||||
app_build_command: ${{ vars.APP_BUILD_COMMAND }}
|
|
||||||
app_location: ${{ vars.APP_LOCATION }}
|
|
||||||
api_build_command: ${{ vars.API_BUILD_COMMAND }}
|
|
||||||
api_location: ${{ vars.API_LOCATION}}
|
|
||||||
output_location: ${{ vars.OUTPUT_LOCATION }}
|
|
||||||
deployment_environment: 'staging'
|
|
||||||
|
|
||||||
close_pull_request_job:
|
|
||||||
if: github.event_name == 'pull_request' && github.event.action == 'closed'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Close Pull Request Job
|
|
||||||
steps:
|
|
||||||
- name: Close Pull Request
|
|
||||||
id: closepullrequest
|
|
||||||
uses: Azure/static-web-apps-deploy@v1
|
|
||||||
with:
|
|
||||||
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
|
|
||||||
action: 'close'
|
|
||||||
47
infrastructure/api.tf
Normal file
47
infrastructure/api.tf
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
resource "azurerm_service_plan" "service_plan" {
|
||||||
|
name = "noahspan-flying-api-service-plan"
|
||||||
|
resource_group_name = data.azurerm_resource_group.resource_group.name
|
||||||
|
location = data.azurerm_resource_group.resource_group.location
|
||||||
|
os_type = "Linux"
|
||||||
|
sku_name = "Y1"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "azurerm_linux_function_app" "function_app_dev" {
|
||||||
|
name = "noahspanflyingapidev"
|
||||||
|
resource_group_name = data.azurerm_resource_group.resource_group.name
|
||||||
|
location = data.azurerm_resource_group.resource_group.location
|
||||||
|
service_plan_id = azurerm_service_plan.service_plan.id
|
||||||
|
storage_account_name = azurerm_storage_account.storage_account_dev.name
|
||||||
|
storage_account_access_key = azurerm_storage_account.storage_account_dev.primary_access_key
|
||||||
|
|
||||||
|
app_settings = {
|
||||||
|
"CLIENT_ID" = "${var.CLIENT_ID}"
|
||||||
|
"CLIENT_SECRET" = "${var.CLIENT_SECRET}"
|
||||||
|
"TENANT_ID" = "${var.TENANT_ID}"
|
||||||
|
"AZURE_STORAGE_ACCOUNT_NAME" = azurerm_storage_account.storage_account_dev.name
|
||||||
|
"AZURE_STORAGE_ACCOUNT_KEY" = azurerm_storage_account.storage_account_dev.primary_access_key
|
||||||
|
"AZURE_STORAGE_ACCOUNT_URL" = azurerm_storage_account.storage_account_dev.primary_table_host
|
||||||
|
}
|
||||||
|
|
||||||
|
auth_settings_v2 {
|
||||||
|
active_directory_v2 {
|
||||||
|
client_id = var.CLIENT_ID
|
||||||
|
tenant_auth_endpoint = "https://login.microsoftonline.com/${var.TENANT_ID}/v2.0/"
|
||||||
|
client_secret_setting_name = "CLIENT_SECRET"
|
||||||
|
}
|
||||||
|
|
||||||
|
login {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
site_config {
|
||||||
|
application_stack {
|
||||||
|
node_version = 20
|
||||||
|
}
|
||||||
|
|
||||||
|
cors {
|
||||||
|
allowed_origins = [ azurerm_static_web_app.static_web_app.default_host_name ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,9 @@
|
|||||||
# module "static_web_app" {
|
|
||||||
# source = "github.com/noahspannbauer/noahspan-root/infrastructure/modules/static_web_app"
|
|
||||||
# region = var.REGION
|
|
||||||
# resource_group_name = data.azurerm_resource_group.resource_group.name
|
|
||||||
# static_web_app_name = var.STATIC_WEB_APP_NAME
|
|
||||||
# custom_domain_name_count = var.CUSTOM_DOMAIN_NAME_COUNT
|
|
||||||
# domain_name = var.DOMAIN_NAME
|
|
||||||
# subdomain_name = var.SUBDOMAIN_NAME
|
|
||||||
# }
|
|
||||||
|
|
||||||
resource "azurerm_static_web_app" "static_web_app" {
|
resource "azurerm_static_web_app" "static_web_app" {
|
||||||
name = var.STATIC_WEB_APP_NAME
|
name = var.STATIC_WEB_APP_NAME
|
||||||
resource_group_name = data.azurerm_resource_group.resource_group.name
|
resource_group_name = data.azurerm_resource_group.resource_group.name
|
||||||
location = var.REGION
|
location = var.REGION
|
||||||
|
sku_size = "Free"
|
||||||
|
sku_tier = "Free"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "azurerm_dns_cname_record" "dns_cname_record" {
|
resource "azurerm_dns_cname_record" "dns_cname_record" {
|
||||||
|
|||||||
@@ -26,3 +26,16 @@ variable "STORAGE_ACCOUNT_NAME" {
|
|||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "CLIENT_ID" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "CLIENT_SECRET" {
|
||||||
|
type = string
|
||||||
|
sensitive = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "TENANT_ID" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user