Skip to content

Commit

Permalink
chore: consolidating builds
Browse files Browse the repository at this point in the history
  • Loading branch information
devops-chris committed Dec 28, 2023
1 parent fc8477b commit 7a49471
Show file tree
Hide file tree
Showing 6 changed files with 227 additions and 124 deletions.
2 changes: 1 addition & 1 deletion .github/actions/tf-apply/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/tf-plan/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
158 changes: 79 additions & 79 deletions .github/workflows/dev_frontend_asa_pr.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
# }
86 changes: 43 additions & 43 deletions .github/workflows/dev_frontend_asa_pr_merge.yml
Original file line number Diff line number Diff line change
@@ -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
72 changes: 72 additions & 0 deletions .github/workflows/dev_frontend_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}"
}
31 changes: 31 additions & 0 deletions .github/workflows/dev_frontend_pr_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7a49471

Please sign in to comment.