Skip to content

Commit

Permalink
chore: restructured
Browse files Browse the repository at this point in the history
  • Loading branch information
devops-chris committed Dec 15, 2023
1 parent 4b0524e commit 2ab4e19
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 73 deletions.
5 changes: 4 additions & 1 deletion .github/actions/tf-apply/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ inputs:
pr_id:
description: 'Pull request ID'
required: true
plan_workflow_file:
description: 'Filename of workflow containing the tf plan artifact.'
required: true

runs:
using: "composite"
Expand Down Expand Up @@ -53,7 +56,7 @@ runs:
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{ inputs.github_token }}
workflow: plan.yaml
workflow: ${{ inputs.plan_workflow_file }}
pr: ${{ inputs.pr_id }}
name: ${{ inputs.pr_id }}-tf-plan
path: ${{ inputs.terraform_directory }}
Expand Down
47 changes: 16 additions & 31 deletions .github/workflows/dev_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
Expand All @@ -27,7 +27,7 @@ jobs:
- name: Install dependencies
working-directory: ${{ env.WORKING_DIR }}
run: bun install

- name: Build Frontend
working-directory: ${{ env.WORKING_DIR }}
run: bun run build
Expand All @@ -37,14 +37,24 @@ jobs:
with:
name: ${{ env.WORKING_DIR }}-${{ env.ENVIRONMENT }}-build-${{ github.sha }}
path: ${{ env.WORKING_DIR }}/build

plan-deploy:
deploy:
needs: build
permissions:
pull-requests: write

runs-on: ubuntu-latest
steps:
# - name: Debug Info
# run: |
# echo "Event Name: ${{ github.event_name }}"
# echo "Event Action: ${{ github.event.action }}"
# echo "Pull Request Number: ${{ github.event.pull_request.number }}"
# echo "Pull Request State: ${{ github.event.pull_request.state }}"
# echo "Pull Request Merged: ${{ github.event.pull_request.merged }}"
# echo "GitHub Event: ${{ toJson(github.event) }}"
# if: always()

- uses: actions/checkout@v3

- name: Download Frontend Artifacts
Expand All @@ -56,6 +66,8 @@ jobs:
- name: Get PR ID
id: pr-id
shell: bash
env:
GITHUB_REF: ${{ inputs.github_ref }}
run: |
PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
Expand All @@ -76,30 +88,3 @@ jobs:
"environment": "${{ env.ENVIRONMENT }}",
"commit_hash": "${{ github.sha }}"
}
apply-deploy:
if: ${{ github.event.pull_request.closed }} && ${{ github.event.pull_request.merged }}
needs: plan-deploy
permissions:
pull-requests: write

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Terraform Apply
uses: ./.github/actions/tf-apply
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: ${{ steps.pr-id.outputs.PR_NUMBER }}
# tf_vars: |
# {
# "environment": "${{ env.ENVIRONMENT }}",
# "commit_hash": "${{ github.sha }}"
# }
83 changes: 42 additions & 41 deletions .github/workflows/dev_pr_merge.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,47 @@
# name: Development Front End Pull Request Merge
name: Development Front End Pull Request Merge

# on:
# pull_request:
# types:
# - closed
# branches:
# - development
# paths:
# - 'frontend/**'
on:
pull_request:
types:
- closed
branches:
- development
paths:
- 'frontend/**'

# env:
# TERRAFORM_VERSION: "1.2.9"
# TF_IN_AUTOMATION: "True"
# ENVIRONMENT: "dev"
env:
TERRAFORM_VERSION: "1.2.9"
TF_IN_AUTOMATION: "True"
ENVIRONMENT: "dev"

# jobs:
# terraform_apply:
# runs-on: ubuntu-latest
# if: ${{ github.event.pull_request.merged }}
# steps:
# - uses: actions/checkout@v3
jobs:
terraform_apply:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.merged }}
steps:
- uses: actions/checkout@v3

# - name: Get PR ID
# id: pr-id
# shell: bash
# run: |
# PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
# echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
- name: Get PR ID
id: pr-id
shell: bash
run: |
PR_NUMBER=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
# - name: Terraform Apply
# uses: ./.github/actions/tf-apply
# 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: ${{ steps.pr-id.outputs.PR_NUMBER }}
# # tf_vars: |
# # {
# # "environment": "${{ env.ENVIRONMENT }}",
# # "commit_hash": "${{ github.sha }}"
# # }
- name: Terraform Apply
uses: ./.github/actions/tf-apply
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: ${{ steps.pr-id.outputs.PR_NUMBER }}
plan_workflow_file: dev_pr.yml
# tf_vars: |
# {
# "environment": "${{ env.ENVIRONMENT }}",
# "commit_hash": "${{ github.sha }}"
# }

0 comments on commit 2ab4e19

Please sign in to comment.