Feature/33 api fails when no pilots or logbook entries #35

Merged
noahspannbauer merged 85 commits from feature/33-api-fails-when-no-pilots-or-logbook-entries into main 2025-02-02 18:24:48 -05:00
14 changed files with 130 additions and 107 deletions
Showing only changes of commit 5e21ad5c30 - Show all commits

View File

@@ -2,7 +2,7 @@ name: 'API Build and Deploy'
on:
workflow_call:
inputs:
calling_workflow:
environment_name:
required: true
type: string
version_number:
@@ -12,7 +12,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
environment: ${{ inputs.calling_workflow }}
environment: ${{ inputs.environment_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
@@ -44,36 +44,26 @@ jobs:
pnpm --filter api build
- name: Deploy
if: ${{ github.event_name != 'pull_request' }}
run: |
pnpm --filter api --prod deploy ./.prod/api
- 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: Setup Docker Buildx
if: ${{ github.event_name != 'pull_request' }}
uses: docker/setup-buildx-action@v3
- name: Build and push to registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/build-push-action@v6
with:
push: true
tags: noahspan/flying-api:${{ inputs.version_number }}
context: .
target: api
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.calling_workflow }}
needs: build
steps:
- name: Log in to Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Update Container App
run: |
az containerapp update --name flying-api-${{ inputs.calling_workflow }} --revision-suffix ${{ inputs.version_number }} --resource-group noahspan --image docker.io/noahspan/flying-api:${{ inputs.version_number }}

View File

@@ -44,36 +44,26 @@ jobs:
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/flying-app:${{ inputs.version_number }}
context: .
target: app
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.calling_workflow }}
needs: build
steps:
- name: Log in to Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Update Container App
run: |
az containerapp update --name flying-app-${{ inputs.calling_workflow }} --revision-suffix ${{ inputs.version_number }} --resource-group noahspan --image docker.io/noahspan/flying-app:${{ inputs.version_number }}

27
.github/workflows/deploy.yaml vendored Normal file
View File

@@ -0,0 +1,27 @@
name: Deploy
on:
workflow_call:
inputs:
app_name:
required: true
type: string
environment_name:
required: true
type: string
version_number:
required: true
type: string
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment_name }}
steps:
- name: Log in to Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Update Container App
run: |
az containerapp update --name ${{ inputs.app_name }}}}-${{ inputs.environment_name }} --revision-suffix ${{ inputs.version_number }} --resource-group noahspan --image docker.io/noahspan/${{ inputs.app_name }}:${{ inputs.version_number }}

42
.github/workflows/main.yaml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: Main
on:
push:
branches:
- main
jobs:
build-api:
name: build-api
uses: ./.github/workflows/api_build.yaml
with:
environment_name: test
version_number: ${{ github.run_id }}
secrets: inherit
deploy-api:
name: deploy-api
needs: build-api
uses: ./.github/workflows/deploy.yaml
with:
app_name: flying-app
environment_name: test
version_number: ${{ github.run_id }}
secrets: inherit
build-app:
name: build-app
uses: ./.github/workflows/app_build.yaml
with:
environment_name: test
version_number: ${{ github.run_id }}
secrets: inherit
deploy-app:
name: deploy-app
needs: build-app
uses: ./.github/workflows/deploy.yaml
with:
app_name: flying-app
environment_name: test
version_number: ${{ github.run_id }}
secrets: inherit

View File

@@ -2,25 +2,20 @@ 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
build-api:
name: build-api
uses: ./.github/workflows/api_build.yaml
with:
calling_workflow: pull_request
environment_name: pull_request
version_number: ${{ github.run_id }}
secrets: inherit
build-deploy-app:
if: github.event_name == 'pull_request' && github.event.action != 'closed'
name: build-deploy-app
uses: ./.github/workflows/app.yaml
build-app:
name: build-app
uses: ./.github/workflows/app_build.yaml
with:
calling_workflow: pull_request
environment_name: pull_request
version_number: ${{ github.run_id }}
secrets: inherit

42
.github/workflows/tag.yaml vendored Normal file
View File

@@ -0,0 +1,42 @@
name: Tag
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build-api:
name: build-api
uses: ./.github/workflows/api_build.yaml
with:
environment_name: prod
version_number: ${{ github.run_id }}
secrets: inherit
deploy-api:
name: deploy-api
needs: build-api
uses: ./.github/workflows/deploy.yaml
with:
app_name: flying-api
environment_name: prod
version_number: ${{ github.run_id }}
secrets: inherit
build-app:
name: build-app
uses: ./.github/workflows/app_build.yaml
with:
environment_name: prod
version_number: ${{ github.run_id }}
secrets: inherit
deploy-app:
name: deploy-app
needs: build-app
uses: ./.github/workflows/deploy.yaml
with:
app_name: flying-app
environment_name: prod
version_number: ${{ github.run_id }}
secrets: inherit

View File

@@ -1,20 +0,0 @@
data "azurerm_app_configuration" "app_configuration" {
name = "noahspan-appconfig"
resource_group_name = data.azurerm_resource_group.resource_group.name
}
resource "azurerm_app_configuration_feature" "pilots_app_configuration_feature" {
configuration_store_id = data.azurerm_app_configuration.app_configuration.id
description = "Feature flag for pilots page"
name = "flying-pilots"
label = var.WORKSPACE
enabled = false
}
resource "azurerm_app_configuration_feature" "logbook_app_configuration_feature" {
configuration_store_id = data.azurerm_app_configuration.app_configuration.id
description = "Feature flag for logbook page"
name = "flying-logbook"
label = var.WORKSPACE
enabled = false
}

View File

@@ -1,76 +1,60 @@
locals {
container_app_app_name = {
dev = "flying-app-dev"
test = "flying-app-test"
prod = "flying-app-prod"
}
container_app_app_container_image = {
dev = "noahspan/flying-app:v0.0.1"
test = "noahspan/flying-app:v0.0.1"
prod = "noahspan/flying-app:v0.0.1"
}
container_app_app_container_name = {
dev = "flying-app-dev"
test = "flying-app-test"
prod = "flying-app-prod"
}
container_app_app_redirect_url = {
dev = "https://flying-app-dev.greensea-e83e7646.centralus.azurecontainerapps.io"
}
container_app_api_name = {
dev = "flying-api-dev"
test = "flying-api-test"
prod = "flying-api-prod"
}
container_app_api_container_image = {
dev = "noahspan/flying-api:v0.0.1"
test = "noahspan/flying-api:v0.0.1"
prod = "noahspan/flying-api:v0.0.1"
}
container_app_api_container_name = {
dev = "flying-api-dev"
test = "flying-api-test"
prod = "flying-api-prod"
}
container_app_api_dapr_app_id = {
dev = "flyingapidev"
test = "flyingapitest"
prod = "flyingpapiprod"
}
container_app_environment_name = {
dev = "flying-dev"
test = "flying-test"
prod = "flying-prod"
}
logbook_feature_flag_active = {
dev = "true"
test = "true"
prod = "true"
}
log_analytics_workspace_name = {
dev = "flying-log-analytics-workspace-dev"
test = "flying-log-analytics-workspace-test"
prod = "flying-log-analytics-workspace-prod"
}
pilots_feature_flag_active = {
dev = "true"
test = "true"
prod = "true"
}
storage_account_name = {
dev = "noahspanflyingdev"
test = "noahspanflyingtest"
prod = "noahspanflyingprod"
}

View File

@@ -14,10 +14,6 @@ output "container_app_api_name" {
value = local.container_app_api_name[var.environment]
}
output "container_app_app_redirect_url" {
value = local.container_app_app_redirect_url[var.environment]
}
output "container_app_api_container_image" {
value = local.container_app_api_container_image[var.environment]
}

View File

@@ -1,2 +0,0 @@

View File

@@ -1,8 +0,0 @@
# output "api_key" {
# value = azurerm_static_web_app.static_web_app.api_key
# sensitive = true
# }
# output "default_host_name" {
# value = azurerm_static_web_app.static_web_app.default_host_name
# }

View File

@@ -1,8 +1,3 @@
provider "azurerm" {
features {
key_vault {
purge_soft_deleted_certificates_on_destroy = true
recover_soft_deleted_secrets = true
}
}
features {}
}

View File

@@ -6,10 +6,6 @@ variable "APP_SUBDOMAIN_NAME" {
type = string
}
variable "AZURE_STORAGE_CONNECTION_STRING" {
type = string
}
variable "CLIENT_ID" {
type = string
}
@@ -32,10 +28,6 @@ variable "DOMAIN_NAME" {
type = string
}
variable "CUSTOM_DOMAIN_NAME_COUNT" {
type = number
}
variable "REGION" {
type = string
}