From 7a49471e460817039675e50ca55189e42cf16abc Mon Sep 17 00:00:00 2001 From: Christopher Lindsay Date: Thu, 28 Dec 2023 09:50:56 -0500 Subject: [PATCH] chore: consolidating builds --- .github/actions/tf-apply/action.yaml | 2 +- .github/actions/tf-plan/action.yaml | 2 +- .github/workflows/dev_frontend_asa_pr.yml | 158 +++++++++--------- .../workflows/dev_frontend_asa_pr_merge.yml | 86 +++++----- .github/workflows/dev_frontend_pr.yml | 72 ++++++++ .github/workflows/dev_frontend_pr_merge.yml | 31 ++++ 6 files changed, 227 insertions(+), 124 deletions(-) diff --git a/.github/actions/tf-apply/action.yaml b/.github/actions/tf-apply/action.yaml index c6066ac42a..54125dc616 100644 --- a/.github/actions/tf-apply/action.yaml +++ b/.github/actions/tf-apply/action.yaml @@ -78,7 +78,7 @@ runs: github_token: ${{ inputs.github_token }} workflow: ${{ inputs.plan_workflow_file }} pr: ${{ inputs.pr_id }} - name: ${{ inputs.pr_id }}-tf-plan + name: ${{ inputs.terraform_directory }}/${{ inputs.pr_id }}-tf-plan path: ${{ inputs.terraform_directory }} # - name: Terraform Apply diff --git a/.github/actions/tf-plan/action.yaml b/.github/actions/tf-plan/action.yaml index f576ed67ea..cfe6a74ad3 100644 --- a/.github/actions/tf-plan/action.yaml +++ b/.github/actions/tf-plan/action.yaml @@ -85,7 +85,7 @@ runs: id: save-artifact uses: actions/upload-artifact@v3 with: - name: ${{ inputs.pr_id }}-tf-plan + name: ${{ inputs.terraform_directory }}/${{ inputs.pr_id }}-tf-plan path: ${{ inputs.terraform_directory }}/tfplan - name: Comment Plan diff --git a/.github/workflows/dev_frontend_asa_pr.yml b/.github/workflows/dev_frontend_asa_pr.yml index d4cc055f4c..52f30e1076 100644 --- a/.github/workflows/dev_frontend_asa_pr.yml +++ b/.github/workflows/dev_frontend_asa_pr.yml @@ -1,91 +1,91 @@ -name: Dev FE ASA Pull Request +# name: Dev FE ASA Pull Request -on: - pull_request: - branches: - - development - paths: - - 'frontend/**' +# on: +# pull_request: +# branches: +# - development +# paths: +# - 'frontend/**' -env: - TERRAFORM_VERSION: "1.5.7" - TF_IN_AUTOMATION: "True" - ENVIRONMENT: "dev" - WORKING_DIR: "frontend" +# env: +# TERRAFORM_VERSION: "1.5.7" +# TF_IN_AUTOMATION: "True" +# ENVIRONMENT: "dev" +# WORKING_DIR: "frontend" -jobs: - build: - permissions: - pull-requests: write - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 +# jobs: +# build: +# permissions: +# pull-requests: write +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 - - name: Setup Bun - uses: oven-sh/setup-bun@v1 - with: - bun-version: latest +# - name: Setup Bun +# uses: oven-sh/setup-bun@v1 +# with: +# bun-version: latest - - name: Install dependencies - working-directory: ${{ env.WORKING_DIR }} - run: bun install +# - name: Install dependencies +# working-directory: ${{ env.WORKING_DIR }} +# run: bun install - # - name: Build Frontend - # working-directory: ${{ env.WORKING_DIR }} - # run: bun run build +# # - name: Build Frontend +# # working-directory: ${{ env.WORKING_DIR }} +# # run: bun run build - - name: Build Bun - uses: ./.github/actions/tf-apply - with: - terraform_directory: "terraform/eus/${{ env.ENVIRONMENT }}/${{ env.WORKING_DIR }}_asa/build_bun" - terraform_version: ${{ env.TERRAFORM_VERSION }} - azure_client_id: ${{ secrets.ARM_CLIENT_ID }} - azure_client_secret: ${{ secrets.ARM_CLIENT_SECRET }} - azure_subscription_id: ${{ secrets.ARM_SUBSCRIPTION_ID }} - azure_tenant_id: ${{ secrets.ARM_TENANT_ID }} - github_token: ${{ secrets.GITHUB_TOKEN }} - pr_id: ${{ github.event.pull_request.number }} - tf_vars: | - { - "environment": "${{ env.ENVIRONMENT }}", - "commit_hash": "${{ github.event.pull_request.number }}", - "frontend_dir": "../../../../../frontend" - } +# - name: Build Bun +# uses: ./.github/actions/tf-apply +# with: +# terraform_directory: "terraform/eus/${{ env.ENVIRONMENT }}/${{ env.WORKING_DIR }}_asa/build_bun" +# terraform_version: ${{ env.TERRAFORM_VERSION }} +# azure_client_id: ${{ secrets.ARM_CLIENT_ID }} +# azure_client_secret: ${{ secrets.ARM_CLIENT_SECRET }} +# azure_subscription_id: ${{ secrets.ARM_SUBSCRIPTION_ID }} +# azure_tenant_id: ${{ secrets.ARM_TENANT_ID }} +# github_token: ${{ secrets.GITHUB_TOKEN }} +# pr_id: ${{ github.event.pull_request.number }} +# tf_vars: | +# { +# "environment": "${{ env.ENVIRONMENT }}", +# "commit_hash": "${{ github.event.pull_request.number }}", +# "frontend_dir": "../../../../../frontend" +# } - - name: Archive Artifacts - uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 #v4.0.0 - with: - name: ${{ env.WORKING_DIR }}-${{ env.ENVIRONMENT }}-build-${{ github.event.pull_request.number }} - path: ${{ env.WORKING_DIR }}/build +# - name: Archive Artifacts +# uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 #v4.0.0 +# with: +# name: ${{ env.WORKING_DIR }}-${{ env.ENVIRONMENT }}-build-${{ github.event.pull_request.number }} +# path: ${{ env.WORKING_DIR }}/build - plan-deploy: - needs: build - permissions: - pull-requests: write +# plan-deploy: +# needs: build +# permissions: +# pull-requests: write - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 - - name: Download Frontend Artifacts - uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 #v4.1 - with: - name: ${{ env.WORKING_DIR }}-${{ env.ENVIRONMENT }}-build-${{ github.event.pull_request.number }} - path: ${{ env.WORKING_DIR }}/build +# - name: Download Frontend Artifacts +# uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 #v4.1 +# with: +# name: ${{ env.WORKING_DIR }}-${{ env.ENVIRONMENT }}-build-${{ github.event.pull_request.number }} +# path: ${{ env.WORKING_DIR }}/build - - name: Terraform Plan - uses: ./.github/actions/tf-plan - with: - terraform_directory: "terraform/eus/${{ env.ENVIRONMENT }}/frontend_asa" - terraform_version: ${{ env.TERRAFORM_VERSION }} - azure_client_id: ${{ secrets.ARM_CLIENT_ID }} - azure_client_secret: ${{ secrets.ARM_CLIENT_SECRET }} - azure_subscription_id: ${{ secrets.ARM_SUBSCRIPTION_ID }} - azure_tenant_id: ${{ secrets.ARM_TENANT_ID }} - github_token: ${{ secrets.GITHUB_TOKEN }} - pr_id: ${{ github.event.pull_request.number }} - tf_vars: | - { - "environment": "${{ env.ENVIRONMENT }}", - "commit_hash": "${{ github.event.pull_request.number }}" - } +# - name: Terraform Plan +# uses: ./.github/actions/tf-plan +# with: +# terraform_directory: "terraform/eus/${{ env.ENVIRONMENT }}/frontend_asa" +# terraform_version: ${{ env.TERRAFORM_VERSION }} +# azure_client_id: ${{ secrets.ARM_CLIENT_ID }} +# azure_client_secret: ${{ secrets.ARM_CLIENT_SECRET }} +# azure_subscription_id: ${{ secrets.ARM_SUBSCRIPTION_ID }} +# azure_tenant_id: ${{ secrets.ARM_TENANT_ID }} +# github_token: ${{ secrets.GITHUB_TOKEN }} +# pr_id: ${{ github.event.pull_request.number }} +# tf_vars: | +# { +# "environment": "${{ env.ENVIRONMENT }}", +# "commit_hash": "${{ github.event.pull_request.number }}" +# } diff --git a/.github/workflows/dev_frontend_asa_pr_merge.yml b/.github/workflows/dev_frontend_asa_pr_merge.yml index 34fd95fe67..4d43180787 100644 --- a/.github/workflows/dev_frontend_asa_pr_merge.yml +++ b/.github/workflows/dev_frontend_asa_pr_merge.yml @@ -1,48 +1,48 @@ -name: Dev FE ASA Pull Request Merged +# name: Dev FE ASA Pull Request Merged -on: - pull_request: - types: - - closed - branches: - - development - paths: - - 'frontend/**' +# on: +# pull_request: +# types: +# - closed +# branches: +# - development +# paths: +# - 'frontend/**' -env: - TERRAFORM_VERSION: "1.5.7" - TF_IN_AUTOMATION: "True" - ENVIRONMENT: "dev" - WORKING_DIR: "frontend" +# env: +# TERRAFORM_VERSION: "1.5.7" +# TF_IN_AUTOMATION: "True" +# ENVIRONMENT: "dev" +# WORKING_DIR: "frontend" -jobs: - apply-deploy: - permissions: - pull-requests: write - runs-on: ubuntu-latest - if: ${{ github.event.pull_request.merged }} - steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 +# jobs: +# apply-deploy: +# permissions: +# pull-requests: write +# runs-on: ubuntu-latest +# if: ${{ github.event.pull_request.merged }} +# steps: +# - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 - - name: Load Archived build - id: download-plan - uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d #v3.0.0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - workflow: ${{ env.ENVIRONMENT }}_${{ env.WORKING_DIR }}_asa_pr.yml - pr: ${{ github.event.pull_request.number }} - name: ${{ env.WORKING_DIR }}-${{ env.ENVIRONMENT }}-build-${{ github.event.pull_request.number }} - path: ${{ env.WORKING_DIR }}/build +# - name: Load Archived build +# id: download-plan +# uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d #v3.0.0 +# with: +# github_token: ${{ secrets.GITHUB_TOKEN }} +# workflow: ${{ env.ENVIRONMENT }}_${{ env.WORKING_DIR }}_asa_pr.yml +# pr: ${{ github.event.pull_request.number }} +# name: ${{ env.WORKING_DIR }}-${{ env.ENVIRONMENT }}-build-${{ github.event.pull_request.number }} +# path: ${{ env.WORKING_DIR }}/build - - name: Terraform Apply - uses: ./.github/actions/tf-apply - with: - terraform_directory: "terraform/eus/${{ env.ENVIRONMENT }}/${{ env.WORKING_DIR }}_asa" - terraform_version: ${{ env.TERRAFORM_VERSION }} - azure_client_id: ${{ secrets.ARM_CLIENT_ID }} - azure_client_secret: ${{ secrets.ARM_CLIENT_SECRET }} - azure_subscription_id: ${{ secrets.ARM_SUBSCRIPTION_ID }} - azure_tenant_id: ${{ secrets.ARM_TENANT_ID }} - github_token: ${{ secrets.GITHUB_TOKEN }} - pr_id: ${{ github.event.pull_request.number }} - plan_workflow_file: ${{ env.ENVIRONMENT }}_${{ env.WORKING_DIR }}_asa_pr.yml +# - name: Terraform Apply +# uses: ./.github/actions/tf-apply +# with: +# terraform_directory: "terraform/eus/${{ env.ENVIRONMENT }}/${{ env.WORKING_DIR }}_asa" +# terraform_version: ${{ env.TERRAFORM_VERSION }} +# azure_client_id: ${{ secrets.ARM_CLIENT_ID }} +# azure_client_secret: ${{ secrets.ARM_CLIENT_SECRET }} +# azure_subscription_id: ${{ secrets.ARM_SUBSCRIPTION_ID }} +# azure_tenant_id: ${{ secrets.ARM_TENANT_ID }} +# github_token: ${{ secrets.GITHUB_TOKEN }} +# pr_id: ${{ github.event.pull_request.number }} +# plan_workflow_file: ${{ env.ENVIRONMENT }}_${{ env.WORKING_DIR }}_asa_pr.yml diff --git a/.github/workflows/dev_frontend_pr.yml b/.github/workflows/dev_frontend_pr.yml index c99ba50686..632d5846b6 100644 --- a/.github/workflows/dev_frontend_pr.yml +++ b/.github/workflows/dev_frontend_pr.yml @@ -32,6 +32,46 @@ jobs: dockerfile: ${{ github.workspace }}/${{ env.WORKING_DIR }}/${{ env.DOCKER_FILE }} image_tag: ${{ github.sha }} + build-asa: + permissions: + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Install dependencies + working-directory: ${{ env.WORKING_DIR }} + run: bun install + + - name: Build Bun + uses: ./.github/actions/tf-apply + with: + terraform_directory: "terraform/eus/${{ env.ENVIRONMENT }}/${{ env.WORKING_DIR }}_asa/build_bun" + terraform_version: ${{ env.TERRAFORM_VERSION }} + azure_client_id: ${{ secrets.ARM_CLIENT_ID }} + azure_client_secret: ${{ secrets.ARM_CLIENT_SECRET }} + azure_subscription_id: ${{ secrets.ARM_SUBSCRIPTION_ID }} + azure_tenant_id: ${{ secrets.ARM_TENANT_ID }} + github_token: ${{ secrets.GITHUB_TOKEN }} + pr_id: ${{ github.event.pull_request.number }} + tf_vars: | + { + "environment": "${{ env.ENVIRONMENT }}", + "commit_hash": "${{ github.event.pull_request.number }}", + "frontend_dir": "../../../../../frontend" + } + + - name: Archive Artifacts + uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 #v4.0.0 + with: + name: ${{ env.WORKING_DIR }}-${{ env.ENVIRONMENT }}-build-${{ github.event.pull_request.number }} + path: ${{ env.WORKING_DIR }}/build + plan-deploy: needs: build permissions: @@ -57,3 +97,35 @@ jobs: "environment": "${{ env.ENVIRONMENT }}", "container_tag": "${{ github.sha }}" } + + plan-asa-deploy: + needs: build-asa + permissions: + pull-requests: write + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 + + - name: Download Frontend Artifacts + uses: actions/download-artifact@f44cd7b40bfd40b6aa1cc1b9b5b7bf03d3c67110 #v4.1 + with: + name: ${{ env.WORKING_DIR }}-${{ env.ENVIRONMENT }}-build-${{ github.event.pull_request.number }} + path: ${{ env.WORKING_DIR }}/build + + - name: Terraform Plan + uses: ./.github/actions/tf-plan + with: + terraform_directory: "terraform/eus/${{ env.ENVIRONMENT }}/frontend_asa" + terraform_version: ${{ env.TERRAFORM_VERSION }} + azure_client_id: ${{ secrets.ARM_CLIENT_ID }} + azure_client_secret: ${{ secrets.ARM_CLIENT_SECRET }} + azure_subscription_id: ${{ secrets.ARM_SUBSCRIPTION_ID }} + azure_tenant_id: ${{ secrets.ARM_TENANT_ID }} + github_token: ${{ secrets.GITHUB_TOKEN }} + pr_id: ${{ github.event.pull_request.number }} + tf_vars: | + { + "environment": "${{ env.ENVIRONMENT }}", + "commit_hash": "${{ github.event.pull_request.number }}" + } \ No newline at end of file diff --git a/.github/workflows/dev_frontend_pr_merge.yml b/.github/workflows/dev_frontend_pr_merge.yml index 6df666af40..fcdb6a6d94 100644 --- a/.github/workflows/dev_frontend_pr_merge.yml +++ b/.github/workflows/dev_frontend_pr_merge.yml @@ -36,3 +36,34 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} pr_id: ${{ github.event.pull_request.number }} plan_workflow_file: ${{ env.ENVIRONMENT }}_${{ env.WORKING_DIR }}_pr.yml + + apply-asa-deploy: + permissions: + pull-requests: write + runs-on: ubuntu-latest + if: ${{ github.event.pull_request.merged }} + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1 + + - name: Load Archived build + id: download-plan + uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d #v3.0.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + workflow: ${{ env.ENVIRONMENT }}_${{ env.WORKING_DIR }}_pr.yml + pr: ${{ github.event.pull_request.number }} + name: ${{ env.WORKING_DIR }}-${{ env.ENVIRONMENT }}-build-${{ github.event.pull_request.number }} + path: ${{ env.WORKING_DIR }}/build + + - name: Terraform Apply + uses: ./.github/actions/tf-apply + with: + terraform_directory: "terraform/eus/${{ env.ENVIRONMENT }}/${{ env.WORKING_DIR }}_asa" + terraform_version: ${{ env.TERRAFORM_VERSION }} + azure_client_id: ${{ secrets.ARM_CLIENT_ID }} + azure_client_secret: ${{ secrets.ARM_CLIENT_SECRET }} + azure_subscription_id: ${{ secrets.ARM_SUBSCRIPTION_ID }} + azure_tenant_id: ${{ secrets.ARM_TENANT_ID }} + github_token: ${{ secrets.GITHUB_TOKEN }} + pr_id: ${{ github.event.pull_request.number }} + plan_workflow_file: ${{ env.ENVIRONMENT }}_${{ env.WORKING_DIR }}_asa_pr.yml