diff --git a/.github/workflows/api.yaml b/.github/workflows/api_build.yaml similarity index 70% rename from .github/workflows/api.yaml rename to .github/workflows/api_build.yaml index a087b34..72b1cac 100644 --- a/.github/workflows/api.yaml +++ b/.github/workflows/api_build.yaml @@ -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 }} diff --git a/.github/workflows/app.yaml b/.github/workflows/app_build.yaml similarity index 75% rename from .github/workflows/app.yaml rename to .github/workflows/app_build.yaml index 28181cc..ac62f44 100644 --- a/.github/workflows/app.yaml +++ b/.github/workflows/app_build.yaml @@ -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 }} diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..8ed0036 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 0000000..0b813d9 --- /dev/null +++ b/.github/workflows/main.yaml @@ -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 diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index af3f378..20549c0 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -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 diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml new file mode 100644 index 0000000..9b5b53d --- /dev/null +++ b/.github/workflows/tag.yaml @@ -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 diff --git a/infrastructure/app_config.tf b/infrastructure/app_config.tf deleted file mode 100644 index f6f6c83..0000000 --- a/infrastructure/app_config.tf +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/infrastructure/config/main.tf b/infrastructure/config/main.tf index 54a6494..7bf5024 100644 --- a/infrastructure/config/main.tf +++ b/infrastructure/config/main.tf @@ -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" } diff --git a/infrastructure/config/outputs.tf b/infrastructure/config/outputs.tf index 2764245..c7103b0 100644 --- a/infrastructure/config/outputs.tf +++ b/infrastructure/config/outputs.tf @@ -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] } diff --git a/infrastructure/container_app.tf b/infrastructure/container_app.tf deleted file mode 100644 index e69de29..0000000 diff --git a/infrastructure/container_app_environment.tf b/infrastructure/container_app_environment.tf deleted file mode 100644 index 139597f..0000000 --- a/infrastructure/container_app_environment.tf +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/infrastructure/outputs.tf b/infrastructure/outputs.tf deleted file mode 100644 index d23490f..0000000 --- a/infrastructure/outputs.tf +++ /dev/null @@ -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 -# } \ No newline at end of file diff --git a/infrastructure/providers.tf b/infrastructure/providers.tf index b7a702b..615cb43 100644 --- a/infrastructure/providers.tf +++ b/infrastructure/providers.tf @@ -1,8 +1,3 @@ provider "azurerm" { - features { - key_vault { - purge_soft_deleted_certificates_on_destroy = true - recover_soft_deleted_secrets = true - } - } + features {} } \ No newline at end of file diff --git a/infrastructure/variables.tf b/infrastructure/variables.tf index 6b3bdbc..76a21dd 100644 --- a/infrastructure/variables.tf +++ b/infrastructure/variables.tf @@ -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 }