Moving app to azure storage #16
70
.github/workflows/app_build.yaml
vendored
70
.github/workflows/app_build.yaml
vendored
@@ -1,70 +0,0 @@
|
||||
name: 'App Build'
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
environment_name:
|
||||
required: true
|
||||
type: string
|
||||
version_number:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
env:
|
||||
VITE_API_URL: ${{ vars.VITE_API_URL }}
|
||||
VITE_CLIENT_ID: ${{ vars.VITE_CLIENT_ID }}
|
||||
VITE_TENANT_ID: ${{ vars.VITE_TENANT_ID }}
|
||||
VITE_REDIRECT_URL: ${{ vars.VITE_REDIRECT_URL }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
environment: ${{ inputs.environment_name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: |
|
||||
app
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
with:
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: 'Setup Node'
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ vars.NODE_VERSION }}
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
pnpm install
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
pnpm --filter app build
|
||||
|
||||
- name: Deploy
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
run: |
|
||||
pnpm --filter app --prod deploy ./.prod/app
|
||||
|
||||
- name: Setup Docker Buildx
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log into Docker Hub
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push to registry
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
push: true
|
||||
tags: noahspan/root-app:${{ inputs.version_number }}
|
||||
context: .
|
||||
target: app
|
||||
96
.github/workflows/app_build_deploy.yaml
vendored
Normal file
96
.github/workflows/app_build_deploy.yaml
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
name: 'App Build'
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
environment_name:
|
||||
required: true
|
||||
type: string
|
||||
version_number:
|
||||
required: true
|
||||
type: string
|
||||
|
||||
env:
|
||||
VITE_API_URL: ${{ vars.VITE_API_URL }}
|
||||
VITE_CLIENT_ID: ${{ vars.VITE_CLIENT_ID }}
|
||||
VITE_TENANT_ID: ${{ vars.VITE_TENANT_ID }}
|
||||
VITE_REDIRECT_URL: ${{ vars.VITE_REDIRECT_URL }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
environment: ${{ inputs.environment_name }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: |
|
||||
app
|
||||
|
||||
- uses: pnpm/action-setup@v4
|
||||
name: Install pnpm
|
||||
with:
|
||||
version: 10
|
||||
run_install: false
|
||||
|
||||
- name: 'Setup Node'
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ vars.NODE_VERSION }}
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
pnpm install
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
pnpm --filter app build
|
||||
|
||||
- name: Deploy
|
||||
uses: azure/login@v2
|
||||
with:
|
||||
client-id: ${{ vars.VITE_CLIENT_ID }}
|
||||
tenant-id: ${{ vars.VITE_TENANT_ID }}
|
||||
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
|
||||
|
||||
- name: Upload
|
||||
if: ${{ inputs.environment_name != 'pull_request' }}
|
||||
uses: azure/CLI@v1
|
||||
with:
|
||||
inlineScript: |
|
||||
az storage blob upload-batch --account-name ${{ vars.AZURE_STORAGE_ACCOUNT_NAME }} --auth-mode key -d '$web' -s ./dist
|
||||
|
||||
# - name: Purge CDN endpoint
|
||||
# if: ${{ inputs.environment_name != 'pull_request' }}
|
||||
# uses: azure/CLI@v1
|
||||
# with:
|
||||
# inlineScript: |
|
||||
# az cdn endpoint purge --content-paths "/*" --profile-name "CDN_PROFILE_NAME" --name "CDN_ENDPOINT" --resource-group "RESOURCE_GROUP"
|
||||
|
||||
- name: logout
|
||||
if: ${{ inputs.environment_name != 'pull_request' }}
|
||||
run: |
|
||||
az logout
|
||||
|
||||
# - name: Deploy
|
||||
# if: ${{ github.event_name != 'pull_request' }}
|
||||
# run: |
|
||||
# pnpm --filter app --prod deploy ./.prod/app
|
||||
|
||||
# - name: Setup Docker Buildx
|
||||
# if: ${{ github.event_name != 'pull_request' }}
|
||||
# uses: docker/setup-buildx-action@v3
|
||||
|
||||
# - name: Log into Docker Hub
|
||||
# if: ${{ github.event_name != 'pull_request' }}
|
||||
# uses: docker/login-action@v3
|
||||
# with:
|
||||
# username: ${{ vars.DOCKERHUB_USERNAME }}
|
||||
# password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
# - name: Build and push to registry
|
||||
# if: ${{ github.event_name != 'pull_request' }}
|
||||
# uses: docker/build-push-action@v6
|
||||
# with:
|
||||
# push: true
|
||||
# tags: noahspan/root-app:${{ inputs.version_number }}
|
||||
# context: .
|
||||
# target: app
|
||||
26
.github/workflows/main.yaml
vendored
26
.github/workflows/main.yaml
vendored
@@ -31,25 +31,25 @@ jobs:
|
||||
version_number: ${{ github.run_id }}
|
||||
secrets: inherit
|
||||
|
||||
build-app:
|
||||
build-deploy-app:
|
||||
if: ${{ needs.changes.outputs.app == 'true' }}
|
||||
name: build-app
|
||||
needs:
|
||||
- changes
|
||||
uses: ./.github/workflows/app_build.yaml
|
||||
uses: ./.github/workflows/app_build_deploy.yaml
|
||||
with:
|
||||
environment_name: test
|
||||
version_number: ${{ github.run_id }}
|
||||
secrets: inherit
|
||||
|
||||
deploy-app:
|
||||
name: deploy-app
|
||||
needs:
|
||||
- changes
|
||||
- build-app
|
||||
uses: ./.github/workflows/deploy.yaml
|
||||
with:
|
||||
app_name: root-app
|
||||
environment_name: test
|
||||
version_number: ${{ github.run_id }}
|
||||
secrets: inherit
|
||||
# deploy-app:
|
||||
# name: deploy-app
|
||||
# needs:
|
||||
# - changes
|
||||
# - build-app
|
||||
# uses: ./.github/workflows/deploy.yaml
|
||||
# with:
|
||||
# app_name: root-app
|
||||
# environment_name: test
|
||||
# version_number: ${{ github.run_id }}
|
||||
# secrets: inherit
|
||||
|
||||
2
.github/workflows/pull_request.yaml
vendored
2
.github/workflows/pull_request.yaml
vendored
@@ -23,7 +23,7 @@ jobs:
|
||||
name: build-app
|
||||
needs:
|
||||
- changes
|
||||
uses: ./.github/workflows/app_build.yaml
|
||||
uses: ./.github/workflows/app_build_deploy.yaml
|
||||
with:
|
||||
environment_name: pull_request
|
||||
version_number: ${{ github.run_id }}
|
||||
|
||||
26
infrastructure/.terraform.lock.hcl
generated
26
infrastructure/.terraform.lock.hcl
generated
@@ -2,20 +2,20 @@
|
||||
# Manual edits may be lost in future updates.
|
||||
|
||||
provider "registry.terraform.io/hashicorp/azurerm" {
|
||||
version = "3.104.0"
|
||||
version = "4.26.0"
|
||||
hashes = [
|
||||
"h1:SSBkZNrevDxOI6j9tVel7/BKX/5xaMYUqx4qhLvrjS4=",
|
||||
"zh:01aa74b1e13c797b20407c37c683b945ffb24462bb39cdaddcf5b3297272c85a",
|
||||
"zh:42c3a69ece44ed6dbd5145dadbdbde9a2e99c3dc0b5a0b28544fd68e796a755d",
|
||||
"zh:48102182e71a10f8337828239d770953fb54e95c4f617a5a327316ba7d9c9aa5",
|
||||
"zh:4c086420f1acc033b5901dc266721a38f43cbab43dedae149df3ccd8d1a3615d",
|
||||
"zh:634e3d701798d699f502c86d1ee591778fa0a46be81a220bd849c0389cd742f1",
|
||||
"zh:6aa0c6cb606dcd8efe90fb9fb872aa5406119264ce2819d8daf35c813e6ba2f7",
|
||||
"zh:8604d0a159b1905d7a92448d5e2e1ec0b3275b9b2d8f7986f4a566f570a6f90c",
|
||||
"zh:912ddd9a43cbb168a58f1af625a8fe111e505c059442ad6126905449e5013877",
|
||||
"zh:9ed54f1e7ae7881611ae659bfbd11db878adc77aa848b920cc0d76a1ab41a2ac",
|
||||
"zh:b507020a566bdbc0dfe868103664361e8ee5549de6edceb7f5d6837dcd8af5a3",
|
||||
"h1:Vdylhj5W0M+J62bOOdvVUlmGB7M5TfaNRcThdb8ydcc=",
|
||||
"zh:0e381bace81028596d60e253bc320bf62d00ae2ec207d7c7e70cdbec5f543334",
|
||||
"zh:32c8cf70e476a4d0e0a2d4cb94b4a4e95c287c5972ca1e8c0f37dc629fbe31cb",
|
||||
"zh:568ebaa4c66fc668dc14c8ff323e47fc7b2ac3b5a5d9eec612de2b6a30164f4c",
|
||||
"zh:596c218810ffb85bc7224574b6ba6dbab9295bfa7490eac98c5ff88beae75710",
|
||||
"zh:75a0e5b60f24684d62944714deb1c790b17c8d4acc93b5cdb45a8187d887b7f1",
|
||||
"zh:7d2abea6ab66a08fed7d1ab8d4f3a8344fe7e2ac76d7409a3e40e8c066df6f22",
|
||||
"zh:7f4db75991fd610b2c0306226e5e1916d4b633cdb0126bc78951dce2365b3418",
|
||||
"zh:95fe307defb6e0dc172855fa597140f3da96655b3c558c140ae51a4a6077f58d",
|
||||
"zh:ae07cdd3c658c0e24d45f1cfadf8b085b18981bcd72a20093ce3f042ed0adf3f",
|
||||
"zh:d2a471b9e42499a7247f873aebd5cbc8df0c6691f02a5c9b556aa00045c06869",
|
||||
"zh:e0299c0f6eae2b1c935f552f76fc49a2e61975eeda9410e3920a004b74d9e750",
|
||||
"zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c",
|
||||
"zh:f7fc6699a0359183911448bf9736777cd6d8ce91fd20d682cf635fa58e2905dd",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -49,11 +49,32 @@ locals {
|
||||
prod = "root-log-analytics-workspace-prod"
|
||||
}
|
||||
|
||||
static_websites = {
|
||||
test = [
|
||||
{
|
||||
error_404_document = "custom_not_found.html"
|
||||
index_document = "index.html"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
storage_account_name = {
|
||||
test = "noahspanroottest"
|
||||
prod = "noahspanrootprod"
|
||||
}
|
||||
|
||||
storage_blobs = {
|
||||
test = [
|
||||
{
|
||||
name = "web"
|
||||
storage_container_name = "$web"
|
||||
type = "Block"
|
||||
content_type = "text/html"
|
||||
source = "index.html"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
storage_tables = {
|
||||
test = ["projects"]
|
||||
prod = ["projects"]
|
||||
|
||||
@@ -38,10 +38,18 @@ output "log_analytics_workspace_name" {
|
||||
value = local.log_analytics_workspace_name[var.environment]
|
||||
}
|
||||
|
||||
output "static_websites" {
|
||||
value = local.static_websites[var.environment]
|
||||
}
|
||||
|
||||
output "storage_account_name" {
|
||||
value = local.storage_account_name[var.environment]
|
||||
}
|
||||
|
||||
output "storage_blobs" {
|
||||
value = local.storage_blobs[var.environment]
|
||||
}
|
||||
|
||||
output "storage_tables" {
|
||||
value = local.storage_tables[var.environment]
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
module "storage" {
|
||||
source = "github.com/noahspannbauer/noahspan-terraform/modules/storage"
|
||||
resource_group_name = var.RESOURCE_GROUP_NAME
|
||||
static_websites = module.environment.static_websites
|
||||
storage_account_name = module.environment.storage_account_name
|
||||
storage_blobs = module.environment.storage_blobs
|
||||
storage_tables = module.environment.storage_tables
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user